Fork me on GitHub
#clj-kondo
<
2022-01-23
>
berkeleytrue21:01:08

I have a cljs file that wraps a javascript library. I'm using a macro to dynamically generate the functions. When I require those generated functions, clj-kondo complains that those variables are unresolved. Is there a way in my clj-kondo configuration to tell it the methods it exports? macro in question: https://github.com/BerkeleyTrue/crypto-egg/blob/master/src/chalk/macro.cljc#L18

borkdude21:01:12

do you have an example call of this macro?

borkdude21:01:33

and example calls of those functions? then I might be able to say yes or no, or it depends

borkdude21:01:22

ok, so each method, represented as keyword, becomes a var right?

berkeleytrue21:01:52

Yes the key becomes the function name in a defn (defn (symbol (name :some-key...

borkdude21:01:15

this is doable. you will have to write a macro in the .clj-kondo directory for this, using the :macroexpand option

borkdude21:01:35

The macro in the .clj-kondo dir can be a simplified one, e.g you just map over the keywords, turn them into symbols and produce a declare call

borkdude21:01:27

(deffoo chalk :foo :bar) -> (declare foo bar)

borkdude21:01:59

Unrelated, since you're using Node.js, you might be interested in doing little scripts with #nbb https://github.com/babashka/nbb/tree/main/examples/chalk

berkeleytrue22:01:11

@U04V15CAJ thanks for your help! I appreciate it. Also, neat (regarding nbb)! Definitely excited for that.

🎉 1