I might be missing something obvious or doing something stupid.
proj/a.cljc:
(ns proj.a
(:require [proj.b :as b]
#?(:cljs [clojure.spec.alpha :as s])))
#?(:cljs
(do
(s/def ::x ::b/x)))
proj/b.cljc
(ns proj.b
(:require [clojure.spec.alpha :as s]))
(s/def ::x any?)
clj-kondo highlights proj.b in [proj.b :as b] above as not used, probably because b is used only within the :cljs reader conditional.
However:
• :as-alias wouldn't work since nothing else loads proj.b
• Moving [proj.b :as b] inside the :cljs reader conditional wouldn't work because the reader would complain with "Invalid token: b/x"
• Requiring it twice, once "raw" and the other time with :as-alias, produces another warning
So seems that I can either unwrap the second reader conditional (works in my case but might not work in general where ::x has different definitions in CLJ and CLJS) or ignore the warning locally.Oh, I guess I can require [proj.b :as b] under the first :cljs and just proj.b under a new :clj. That's... not neat.
> :as-alias wouldn't work since nothing else loads proj.b
huh, I don't understand that one
proj.b has side-effects when it's getting loaded - the definition of the spec.
If nothing loads that namespace, the spec does not exist.
:as-alias does not load the namespace.
#?(:cljs [proj.b :as :b]
:clj [proj.b :as-alias :b])
that's not neat, but it worksAh, right - that's what my first comment in the thread should be.
nothing else loads proj.b. you want it to be loaded in clj as well?
Yes, not all its specs are properly qualified. Shoddy, I know - legacy stuff.
I think there's an open issue for this, also related to #_::b/x being triggered in the reader. the reader should probably not barf on this. there's a JIRA for it
with open issue I meant JIRA, but I think there's also a kondo one for it
Yeah, or (comment ...), I remember it all to well. :)
for now probably an ignore hint on the proj.b :as b is justified
I think even Dustin mentioned it somewhere related to "Clojure is falling apart".
Eh, I went the "not neat" route. To surprise myself in a year, when I get back to this piece of code with no memory of it whatsoever.
"Saving to memory..."
It's like that "1 TB SSD" for 10 € from Temu. :D