This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-21
Channels
- # announcements (1)
- # architecture (392)
- # babashka (3)
- # beginners (1)
- # calva (2)
- # cider (1)
- # clojure (30)
- # clojure-denmark (2)
- # clojure-dev (9)
- # clojure-europe (13)
- # clojure-italy (2)
- # clojure-japan (17)
- # clojure-korea (8)
- # clojure-nl (1)
- # clojure-norway (74)
- # clojure-uk (3)
- # clojurescript (6)
- # code-reviews (8)
- # conjure (1)
- # data-science (1)
- # datascript (7)
- # datomic (1)
- # fulcro (1)
- # graalvm (9)
- # humbleui (3)
- # hyperfiddle (11)
- # leiningen (4)
- # lsp (7)
- # malli (7)
- # off-topic (57)
- # other-languages (9)
- # overtone (7)
- # shadow-cljs (30)
- # sql (15)
- # squint (3)
- # timbre (3)
- # vim (6)
Is :jsdoc
metadata no longer supported? I can't seem to get it to actually output the JSDoc comments in the compiled javascript. This is w/ simple optimizations for a node library.
works just fine. I made an example a bit ago here https://clojurians.slack.com/archives/C03S1L9DN/p1710662438914879?thread_ts=1710421525.090259&cid=C03S1L9DN
hmm... doesn't work for me. I'm trying to add a @param {string} jws
jsdoc string and I can't find it in the output JS
where did you use it? it only works on def and defn? or possibly bindngs, I'm not actually sure
I've tried this:
(defn ^{:export true, :jsdoc ["@param {string} jws"]} verify-jws
[jws]
(-> jws fc/verify-jws clj->js))
and this (following your example above):
(defn ^:export verify-jws {:jsdoc ["@param {string} jws"]}
[jws]
(-> jws fc/verify-jws clj->js))
that looks fine, although I'm unsure what that tag is for? after optimizations that tag will be gone?
for better typescript type declarations
but if that's the case, that would explain why I'm not seeing it 🙂
the typescript compiler can generate them from js sources and can use jsdoc annotations for better type info when they're available
/**
* @param {string} jws
*/
demo.browser.verify_jws = (function demo$browser$verify_jws(jws){
return cljs.core.clj__GT_js(jws);
});
huh, weird
well if its generating them from release
compiled sources then it won't have much luck
closure removes @param
annotations as part of optimizations, they it assumes its for its guidance
we're explicitly using simple optimizations for other reasons
I'd say there is close to zero chance for type annotations to remain in a shape where typescript can find them
it is running shadow-cljs release
so that must be why
ok, I'll give up for now then. just wanted to make sure I wasn't something simple to enable better types
thanks!
I have never done anything with typescript, so I don't know how types would be extracted
it should be fairly easy to generate .d.ts
files using a build hook though, since that can see whats exported and what metadata those vars have
this is where it's documented, in case you're curious: https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html
oh, that could be interesting
probably more work than it's worth right now, but good to know