The ClojureScript compiler happily accepts forms like js/Math.MAX_NUMBER and (js/Math.ceil 3.14) which is not valid Clojure code. The correct way to write these expressions in ClojureScript is (.-MAX_NUMBER js/Math) and (.ceil js/Math 3.14).

The ClojureScript analyzer should at least emit a warning when these bad forms are encountered. Preferably compilation should fail but that would probably break lots of existing code.

I'm having second thoughts about this. Looking at the commit when the js namespace was introduced[1] you can see that, for example (goog.global.Math/exp x) was changed to (js/Math.exp x). I'm thinking maybe the js magic namespace is meant to support these kinds of calls?

Another issue I ran into was when using a js library (paper.js) and I was supposed to translate

var x = new paper.Path()

into ClojureScript. I could not find any way to achieve this except

(let [x (js/paper.Path.)]
...)

There is an assertion[2] in the analyzer that prohibits the following alternative:

(let [x (new (.-Path js/paper))]
...)

Removing the assertion (and the call to 'resolve-existing-var') the above expression seems to work just fine.

This patch creates issues around using constructors provided by libraries outside ClojureScript and GClosure. Also from Rich's original commit support js prefix, it seems like JS style access after the / was actually intended.