This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-31
Channels
- # announcements (20)
- # asami (14)
- # aws (6)
- # babashka (15)
- # beginners (83)
- # biff (6)
- # calva (93)
- # cider (3)
- # clj-kondo (21)
- # cljdoc (106)
- # cljs-dev (32)
- # clojure (165)
- # clojure-dev (78)
- # clojure-europe (54)
- # clojure-italy (9)
- # clojure-nl (9)
- # clojure-norway (24)
- # clojure-uk (4)
- # clojurescript (6)
- # community-development (2)
- # conjure (2)
- # core-typed (14)
- # datahike (4)
- # datomic (2)
- # emacs (40)
- # events (1)
- # fulcro (11)
- # graalvm-mobile (29)
- # graphql (8)
- # honeysql (19)
- # java (1)
- # jobs (1)
- # lsp (232)
- # malli (5)
- # membrane (112)
- # nextjournal (11)
- # off-topic (63)
- # portal (12)
- # re-frame (6)
- # reagent (3)
- # reitit (4)
- # rewrite-clj (2)
- # shadow-cljs (25)
- # tools-deps (6)
(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 somes/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
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.