Fork me on GitHub
#clojurescript
<
2024-08-05
>
octahedrion06:08:17

what's the equivalent of (Something. x y z) or (new Something x y z) using js-interopor oops to avoid externs ? Neither library gives an example.

p-himik06:08:32

> to avoid externs I haven't had to deal with externs in around... five years now? Despite heavily using interop. But I've been using only shadow-cljs throughout all this time, so no clue whether the vanilla compiler changes anything here.

octahedrion07:08:02

(.construct js/Reflect something args) appears to work

p-himik07:08:18

But also, there should be no need for something special in any of the libraries to support (X.). When you write things like (.method x), that .method gets and calls a property, but the name of the property might be changed due to advanced optimizations. So the "get" part can fail due to the names mismatch. But with (X.), you cannot achieve that mismatch at all. Using X means that you already have a reference to X, there's no "get" part here - it has been done during the import of whatever you're using. As for the global things like js/Reflect - IIRC, automatic externs have been working with js/* stuff for ages. Or does plain (js/Reflect. ...) not work for you?

p-himik07:08:46

I would assume that it actually does work. With modern tools, there's barely any need to think about externs. Maybe throw in ^js here and there when you mix both JS interop and CLJS functions, as in (-> (.getItems some-object-from-js-import) (first) (.-name)).

marrs12:08:58

Can anyone tell me why this command is failing? clj -M --main cljs.main --asset-path cljs --target browser --output-dir web/cljs --compile metalist.core I have a static html file in dir web and I'm loading the target js myself with