Fork me on GitHub
Roman Liutikov15:05:30

There's an interesting issue popped out with Closure library that may require a slight change in cljs's codegen. Story: Closure's Jsonp takes an instance of Uri class, which worked fine before, but now (dunno since when) it requires an instance of TrustedResourceUrl which in turn can be constructed from goog.string.Const type that takes a string literal or concatenation of string literals. Now Clojure's str emits [a,b,c].join('') which is not recognized by Closure Compiler as a static string concatenation.

Roman Liutikov15:05:07

My question is should we switch from [a,b,c].join('') to a + b + c?

Roman Liutikov15:05:54

Here's a repro Somehow Closure doesn't warn about Uri not matching required TrustedResourceUrl type But then at runtime you'll get [AssertionError]: Failure: expected object of type TrustedResourceUrl, got '123456' of type object but that's another story


@roman01la you just need to construct the TrustedResourceUrl yourself. it is a bit annoying to construct but nobody is enforcing the closure rules for this so it doesn't matter that you construct it dynamically


nothing will automatically turn Uri into a TrustedResourceUrl so it doesn't matter what str does

Roman Liutikov15:05:20

the issue is that (TrustedResourceUrl. (Const/from (str a b))) fails

Roman Liutikov15:05:32

because (str a b) emits [a,b].join('')

Roman Liutikov15:05:50

Closure exists complaining that [a,b].join('') is not a static concatenation


yeah there is a helper fn somewhere to construct it


with a really long annoying name




goog.html.uncheckedconversions.safeUrlFromStringKnownToSatisfyTypeContract even more fun 😛



Roman Liutikov16:05:38

hm, those still require goog.string.Const as a param

Roman Liutikov16:05:37

ah I see, the param is justification


Can't we open a issue in closure-compiler to make it understand that [a,b].join('') is a static string too?

Roman Liutikov16:05:17

yeah I think that would be best


well [a,b] at not compile time constants so they won't go for that 😛

Roman Liutikov16:05:23

advanced mode is able to fold array join into a string though


I mean you'd need to add the @const annotation probably

Roman Liutikov16:05:17

which means types info is already used for that