You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The type of expressions typeof x === "<type>" will be inferred as x is <type> instead of boolean (x is Function for "function"; maybe x is object | null for "object"?).
Type of expressions x instanceof Class will be inferred as x is Class instead of boolean.
π Motivating Example
Doing this would change the return type of custom type assertion functions, which in turn would help filtering arrays for specific type.
Suggestion
π Search Terms
infer type assertion typeof comparison
β Viability Checklist
My suggestion meets these guidelines:
I am not sure abot this point, it may break some code...
β Suggestion
typeof x === "<type>"
will be inferred asx is <type>
instead ofboolean
(x is Function
for "function"; maybex is object | null
for "object"?).x instanceof Class
will be inferred asx is Class
instead ofboolean
.π Motivating Example
Doing this would change the return type of custom type assertion functions, which in turn would help filtering arrays for specific type.
before:
after:
π» Use Cases
Workaround is adding the type assertion manually:
The text was updated successfully, but these errors were encountered: