Currently, IWithMeta is implemented for functions by wrapping the function in a MetaFn type.
However, this breaks certain expectations about the typeof of the meta-fied value:
(defn Foo [_] "bar") (goog/typeOf Foo) ;; => "function" (goog/typeOf (with-meta Foo {:bar "baz"})) ;; => "object"
The primary case when this is not ideal is when interoping with JS code that does checks using typeof, like React does:
(react-is/isValidElementType Foo) ;; => true (react-is/isValidElementType (with-meta Foo {:bar "baz"})) ;; => false
Ideally, with-meta would preserve the typeof value when possible.
N/A
Currently, IWithMeta is implemented for functions by wrapping the function in a MetaFn type.
However, this breaks certain expectations about the typeof of the meta-fied value:
(defn Foo [_] "bar") (goog/typeOf Foo) ;; => "function" (goog/typeOf (with-meta Foo {:bar "baz"})) ;; => "object"
The primary case when this is not ideal is when interoping with JS code that does checks using typeof, like React does:
(react-is/isValidElementType Foo) ;; => true (react-is/isValidElementType (with-meta Foo {:bar "baz"})) ;; => false
Ideally, with-meta would preserve the typeof value when possible.