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
This condition will always return 'false' since the types '"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"' and 'null' have no overlap.
Actual behavior:
no error
My opinion:
This behavior allows quick null/undefined checks regardless of type information.
but typeof foo === undefined needs to be considered as a typo much more.
The text was updated successfully, but these errors were encountered:
but typeof foo === undefined needs to be considered as a typo much more.
The compiler doesn't special-case typeof in an expression for the purpose of type checking. It looks the same to the compiler as, e.g., stringVar === undefined (which is deliberately allowed, as you've pointed out).
TypeScript Version: 3.2.2
Search Terms: typeof
Code
Expected behavior:
compiler error
Actual behavior:
no error
My opinion:
This behavior allows quick
null/undefined
checks regardless of type information.but
typeof foo === undefined
needs to be considered as a typo much more.The text was updated successfully, but these errors were encountered: