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

Mention ^js annotation in Externs Guide #260

Open
pesterhazy opened this issue Aug 31, 2018 · 3 comments
Open

Mention ^js annotation in Externs Guide #260

pesterhazy opened this issue Aug 31, 2018 · 3 comments
Labels

Comments

@pesterhazy
Copy link

The externs guide mentions type annotations like ^js/Foo.Bar.

Although it doesn't mention it, it's also possible to simply use ^js. (In fact anything like ^js/asdf will work, too.)

Should ^js be the default recommendation? Oftentimes you don't know the correct type of JS objects you're getting back from an NPM lib. Even if you do, using a generic annotation seems to have the same effect, so not sure there are any downsides to simply using ^js everywhere.

@swannodette
Copy link
Member

@pesterhazy that's a good suggestion

@mrrodriguez
Copy link

mrrodriguez commented Jul 10, 2019

I'll note that in recent versions of CLJS using ^js does seem to generate necessary externs via externs inference, however, it also omits a warning about needing to add extern to Object due to it being "ambiguous".
See https://github.com/clojure/clojurescript/blob/v1.10/src/main/clojure/cljs/analyzer.cljc#L480 for where I believe this originates.

It is just a warning, but it can be a little annoying to deal with if using *warn-on-infer* and something like auto-reloading in figwheel where it defaults to not reloading when namespaces have warnings.
Of course you can choose to just not use *warn-on-infer*, but the downside there is that you then don't get the other warnings that may be useful. There is just a lack of granularity on the ^js case.

Also, maybe this isn't the correct place to bring this up?

@mfikes
Copy link
Member

mfikes commented Jul 10, 2019

@mrrodriguez Right, perhaps a JIRA for what you are describing.

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

4 participants