Closed
Description
TypeScript Version: 3.9.4
As specified here, https://tc39.es/ecma262/#sec-instanceofoperator, it should be sufficient for an object to define a function for the Symbol.hasInstance
well-known symbol in order to be used as the right-hand side of the instanceof
operator.
It seems like this was intended to be implemented based on these comments: #12728 (comment)
but for whatever reason that didn't happen it in the PR
Search Terms: Symbol.hasInstance
Code
({}) instanceof {[Symbol.hasInstance]: () => true}
// Running this in the browser evaluates to `true`
Expected behavior:
No type-errors
Actual behavior:
({}) instanceof {[Symbol.hasInstance]: () => true}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
Playground Link: Playground Link
Related Issues: