cljs / api

ClojureScript API parser
http://cljs.github.io/api/
MIT License
193 stars 23 forks source link

`^js` tag #189

Closed shaunlebron closed 1 year ago

shaunlebron commented 1 year ago

question came up here: https://github.com/lilactown/helix/pull/104#discussion_r955408172

discussed with @thheller here: https://clojurians.slack.com/archives/C03S1L9DN/p1664298527478269

^js can effectively be used instead of ^js/React.Element. The extra type info is for readability, but shadow-cljs for example actually throws it away. I think Closure conservatively refuses to mangle recognized property names regardless of the object type.

Looking at both cljs and shadow-cljs codebases, here’s how the ^js tag affects externs. I’ll probably put this on cljs api site soon since there’s much confusion about what actually happens:

added to cljs externs added to shadow-cljs externs
^js => Object.* ShadowJS.prototype.*
^js/React.Element => React.Element.prototype.* ShadowJS.prototype.*