Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created August 9, 2015 00:46
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save swannodette/2527b29ff786d454141f to your computer and use it in GitHub Desktop.
Save swannodette/2527b29ff786d454141f to your computer and use it in GitHub Desktop.
(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