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

add ^js/React.Context hint #109

Merged
merged 1 commit into from
Oct 3, 2022
Merged

Conversation

shaunlebron
Copy link
Contributor

Fixes #103 and #104

Hi @lilactown, this is the only change needed for the above issues. Thank you! 🙏

@aiba
Copy link
Contributor

aiba commented Sep 30, 2022

💙

@lilactown
Copy link
Owner

thanks @shaunlebron ! I haven't been following the full conversation in slack; did you find out that this comment is in fact not true, and we can use the ^js syntax inside of a syntax quote when emitting CLJS code?

@shaunlebron
Copy link
Contributor Author

@lilactown No, ^js in a syntax-quote becomes ^<macro-ns>/js, but this PR uses the explicit type ^js/React.Context to pass symbol resolution.

If you’d like to verify that the typehint generates an extern, here’s a rough trace through the reader, macro evaluation, and cljs analyzer:

^js/React.Context ~context =>

  1. reader translates to => (clojure.core/with-meta context {:tag (clojure.core/quote js/React.Context)})
  2. macro evaluates to => the context macro arg (i.e. symbol or list), attached with metadata {:tag js/React.Context}
  3. analyzes creates a => var/invoke CLJS AST node for the symbol/list, using its :tag metadata as a typehint
  4. analyzer writes => externs when encountering a dot form on an AST node with a js typehint

@lilactown
Copy link
Owner

ohhhh interesting. Nice!

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

Successfully merging this pull request may close these issues.

"Provider" property access getting mangled by :optimizations :advanced
3 participants