Hi, what’s the correct way to require a defalias “var” from another namespace?
You need to ensure the defalias itself is loaded by the time the type checker runs in order of the type checker to find it. In terms of referring to it, you can use a fully qualified ns or a ns alias.
(require '[foo.bar :as-alias f])
(defalias Something f/Bar)
there's no way to refer it into the current ns. it's similar to spec s/def in this this way.
I see, So just to clarify, to import a defalias, we need to use the as-alias in our require statement? I attempted to just use :as and that does not seem to work.
:as should work too
This uses the same mechanism (require '[typed.clojure :as t]) => t/Seqable
okay, cool! I will check it out. I must have done something wrong on my side then.
fwiw even though it's a static type checker the type checker relies on the dynamic state of the repl to pick up the annotation, similar to spec. it's not enough to just save the file containig the defalias, it needs to be evaled.
Got it. I am using clj-reload to reload clojure namespaces.
there's some cleverness behind the scenes so that defaliases can be removed automatically on reload if they are deleted in source. I think it should be compatible with clj-reload, I designed it for tools.namespace. Effectively the alias expires if the Namespace object that originally registered it is gc'ed.
Okay, very cool.