Fork me on GitHub
#cljs-dev
<
2017-05-04
>
rauh07:05:01

It seems that type hints get ignored on any js/... interop. Is that intended?

;; 1. boolean is ignored:
(fn []
  (or ^boolean js/window.x
      false))
;; 2. Works:
(fn []
  (or ^boolean window.x
      false))
;; 3. Works:
(fn []
  (or ^boolean (.-x js/window)
      false))

thheller07:05:31

the :infer-externs code changed that behavior. there was a conversation about this before but I can't remember specifics

thheller07:05:27

I think @darwin encountered this with ^boolean js/goog.DEBUG and the gist of it was to use ^boolean goog/DEBUG since goog is implicitly imported

thheller08:05:26

I wanted meant to try and use the type annotations in the externs for this

thheller08:05:32

but didn't get around to it yet

thheller08:05:53

sort of at odds with the :infer-externs as well 😉

mikethompson08:05:24

Oh, ouch. ^boolean js/goog.DEBUG doesn't work any more?

mikethompson08:05:51

If so, isn't that going to silently break the prod builds for projects which use that construct to inject dev-time features. We certainly do that.

mikethompson08:05:56

We can obviously go through and take off the leading js/ ... but its deadly if it silently changes behavior.

thheller08:05:02

yeah someone should probably report it properly with example

mikethompson08:05:42

We'll test it and report what we find

mikethompson08:05:29

Is this a recent change?

mikethompson08:05:14

Just wondering how far back we'd have to go to find it working (if indeed it is now broken)

thheller08:05:21

whenever :infer-externs was introduced

thheller08:05:28

not sure when that was

darwin10:05:17

@mikethompson I would recommend having tests setup to check that expected DCE happened in advanced builds, the changes/regressions could be caused by Closure Compiler as well

dnolen14:05:15

@mikethompson user supplied type hints should supercede any thing the compiler infers so just a bug - file a report

dnolen14:05:02

in this case it would probably be best to get a test case - one that builds a trivial advanced project and searches the generated code for the correct output

dnolen14:05:44

but it is true that js/goog isn’t something you should be doing

darwin15:05:01

maybe a compile-time warning would be good idea for js/goog usages