We're updating the issue view to help you get more done. 

Preserve type of function with metadata

Description

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:

1 2 3 4 5 6 7 (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:

1 2 3 4 5 (react-is/isValidElementType Foo) ;; => true (react-is/isValidElementType (with-meta Foo {:bar "baz"})) ;; => false

Ideally, with-meta would preserve the typeof value when possible.

Environment

N/A

Status

Assignee

Unassigned

Reporter

Will Acton

Labels

Approval

None

Patch

None

Affects versions

Next
1.10.238

Priority

Minor