Closed
Description
TypeScript Version: 4.1.0-dev
Search Terms:
operator in exception crash unhandled
Code
const hasKey = <A, K extends string | number | symbol>(
thing: A,
key: K,
): boolean => {
return key in thing;
};
hasKey(123, 'hello'); // TypeError exception
Expected behavior:
TS should expect A
to be an object
Actual behavior:
TS didn't detect the potential crash
Related Issues: