Skip to content

Commit 3f3cb6d

Browse files
committed
add experimental unsafe cast
1 parent 5800cfb commit 3f3cb6d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/clojure/cljs/core.cljc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
unsafe-bit-and bit-shift-right-zero-fill mask bitpos caching-hash
4141
defcurried rfn specify! js-this this-as implements? array js-obj
4242
simple-benchmark gen-apply-to js-str es6-iterable load-file* undefined?
43-
specify copy-arguments goog-define js-comment js-inline-comment])])
43+
specify copy-arguments goog-define js-comment js-inline-comment
44+
unsafe-cast])])
4445
#?(:cljs (:require-macros [cljs.core :as core]))
4546
(:require clojure.walk
4647
clojure.set
@@ -879,6 +880,12 @@
879880
(reduce core/str ""))
880881
" */"))))
881882

883+
(core/defmacro unsafe-cast
884+
"EXPERIMENTAL: Subject to change. Unsafely cast a value to a different type."
885+
[t x]
886+
(core/let [cast-expr (core/str "~{} = /** @type {" t "} */ (~{})")]
887+
(core/list 'js* cast-expr x x)))
888+
882889
(core/defmacro js-inline-comment
883890
"Emit an inline JavaScript comment."
884891
[comment]

0 commit comments

Comments
 (0)