Fork me on GitHub
#shadow-cljs
<
2022-11-24
>
Yab Mas11:11:06

Is it possible to solve infer-warnings by placing the ^js type-hint on a function or its return value in some way? I tried a few things but nothing seems to work. For example: This will give me an infer-warning on the .-js-attr call.

(defn interop-wrapper-fn [^js js-obj] (.interopCall js-obj))

  (defn some-fn [^js js-obj] (.-js-attr (interop-wrapper-fn js-obj)))
I would kind of expect that placing a type-hint on the return value of the interop-wrapper-fn as below would solve the issue, but it doesn't.
(defn interop-wrapper-fn ^js [^js js-obj] (.interopCall js-obj))
Ofcourse placing the typehint in the some-fn as below does work but it would be great to solve this centrally. Besides i'm curious about the reason why the method above doesn't work?
(defn some-fn [^js js-obj] (.-js-attr ^js (interop-wrapper-fn js-obj)))

thheller18:11:06

the return value hint should work?

Yab Mas13:11:58

Ok... It really doesn't seem to work for me, so Im probably doing something else wrong. The issue has been sufficiently solved in a different way though. Will look at this later. Thanks for the reply.

mkvlr13:11:21

Since migrating to React 18 & using hooks through reagent I noticed that remounting the app doesn't trigger a re-render of the whole component tree. If I read things correctly react-refresh is a solution to this problem, anybody manage to use with shadow-cljs? I've only found old stuff e.g. https://github.com/facebook/react/issues/17281 from @lilactown but no solution. Appreciate any pointers.

thheller18:11:29

I haven't looked at react-refresh at all

thheller18:11:38

not sure what the state of all that is

mkvlr20:11:54

thanks for the link