Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with infer-externs "goog is not defined in the externs" #512

Closed
olivergeorge opened this issue Nov 4, 2018 · 5 comments
Closed

Error with infer-externs "goog is not defined in the externs" #512

olivergeorge opened this issue Nov 4, 2018 · 5 comments
Labels

Comments

@olivergeorge
Copy link
Contributor

I've turned on :infer-externs and now get a warning doing an advanced optimisations build:

WARNING: target/ios/inferred_externs.js:1: WARNING - name goog is not defined in the externs.
goog.DEBUG;
^^^^

Pretty sure this is caused by the way goog.DEBUG is referred to in the re-frame.interop namespace

(def ^boolean debug-enabled? "@define {boolean}" ^boolean js/goog.DEBUG)

My testing of infer-externs shows this:

; Good
(when ^boolean goog.DEBUG (println "Hello world!"))
(when ^boolean goog/DEBUG (println "Hello world!"))

; Bad
;(when js/goog.DEBUG (println "Hello world!"))
@danielcompton
Copy link
Contributor

Just to clarify, you're saying it looks like the issue is the leading js/ on goog.DEBUG?

@olivergeorge
Copy link
Contributor Author

Yes, seems to be.

$ cat deps.edn 
{:deps {org.clojure/clojurescript {:mvn/version "1.10.439"}}}

$ cat compile-opts.edn 
{:infer-externs   true
 :optimizations      :advanced }

$ cat src/can_i_infer/core.cljs 
(ns can-i-infer.core)

(when js/goog.DEBUG (println "Hello world!"))

$ rm -r out/

$ clj -m cljs.main -co compile-opts.edn -c can-i-infer.core
Nov 05, 2018 3:01:58 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: out/inferred_externs.js:9: WARNING - name goog is not defined in the externs.
goog.DEBUG;
^^^^

Nov 05, 2018 3:01:58 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 1 warning(s)

@mike-thompson-day8
Copy link
Contributor

@olivergeorge any chance you could provide a PR for the fix you see as working?

@olivergeorge
Copy link
Contributor Author

Gladly. Before I do I need an idiom check on goog.DEBUG vs goog/DEBUG. Have asked on Slack.

@mike-thompson-day8
Copy link
Contributor

Fixed via #517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants