I'm a little confused on how any works
s/Any cannot be passed as a (t/Seqable t/Any). But (t/Seqable t/Any) can be passed as t/Any .
With the current annotation for y, you could have (def y :kw) which is not a (t/Seqable t/Any)
if it helps, t/Any is more like Object in Java, and is nothing like any in TypeScript
it's (only) the top of the type hierarchy (TS's any is also the bottom).
is there a bottom type? (never or such)
t/Nothing aka (t/U)
if you need an escape hatch like any, there are a few options.
1. (t/ann ^:no-check foo ...) ignores the definition of vars
2. clojure.core.typed.unsafe/ignore-with-unchecked-cast casts a form to any type.
There'll probably be more ways in the future.
You can also wrap forms in (t/tc-ignore ..) to completely skip them. I think the best balance is ^:no-check + t/tc-ignore atm.
But one of the things that has made typed clojure still interesting to me after all these years was avoiding an any type, so this is the state of things 🙂
the discoverability is very low on this stuff so feel free to keep asking
yeah - so long as this slack keeps history you can maybe use it for copy pasting into a wiki
(t/ann x t/Any)
(def x ",")
(t/ann y t/Any)
(def y ["a"])
(string/join x y)
(comment
(t/check-ns-clj))This code fails with
Type Error (file:/Users/emccue/Development/tyyyyyped/src/tyt.clj:12:1)
Function string/join could not be applied to arguments:
Domains:
t/Any (t/Seqable t/Any)
Arguments:
t/Any t/Any
Ranges:
t/Str
in:
(string/join x y)
Execution error (ExceptionInfo) at clojure.core.typed.errors/print-errors! (errors.cljc:273).
Type Checker: Found 1 error
on type checking - which means that t/Any doesn't satisfy (t/Seqable t/Any), which confuses me some