Created
August 9, 2015 00:46
-
-
Save swannodette/2527b29ff786d454141f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn my-get | |
"@param {*} m | |
@param {*} k | |
@return {nil|Object}" | |
[m k] | |
(get m k)) | |
(defn foo | |
"@param {!Object} x" ;; non-nullable | |
[x] x) | |
(let [m {:foo 1} | |
v (my-get m :foo)] | |
(js/alert (foo v))) ;; type error | |
(defn bar | |
"@param {PersistentVector} x" | |
[x] x) | |
(bar {}) ;; type error | |
;; WARNING: 2 error(s), 1 warning(s), 73.5% typed | |
;; ERROR: JSC_TYPE_MISMATCH. actual parameter 2 of nullable.core.foo.call does not match formal parameter | |
;; found : (Object|null) | |
;; required: Object at /Users/davidnolen/development/clojure/nullable/out/nullable/core.js line 20 : 34 | |
;; ERROR: JSC_TYPE_MISMATCH. actual parameter 2 of nullable.core.bar.call does not match formal parameter | |
;; found : cljs.core.PersistentArrayMap | |
;; required: (cljs.core.PersistentVector|null) at /Users/davidnolen/development/clojure/nullable/out/nullable/core.js line 27 : 28 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment