Fork me on GitHub
#cljs-dev
<
2023-04-16
>
timothypratley03:04:02

Minor type hinting observation:

(fn [^js c] (reset! color-picking (.-hex c)))
^js is required for advanced compilation - seems like a good opportunity to infer that c is a js object due to the .- field access

hifumi12305:04:39

I don't think that will be a good heuristic. For instance, the implementation of persistent vectors will make use of fields like cnt, but it'd be a mistake to type hint cljs vectors with ^js meta, especially since the hints influence how some code is emitted; e.g. (if (and s (next s)) then else) is compiled differently when cljs compiler knows s is a seq and not js object

thheller06:04:49

correct, not all property access automatically implies that the property should not be renamed. it is perfectly fine for properties to get renamed if ALL access to this property is renamed. i.e. in CLJS and Closure JS code all properties can be renamed. the only place it cannot be renamed is for external code, but the compiler cannot infer whether c is from external code or safe to rename. thus hints.