tl;dr why does
const func = (a: unknown) => {
if (a && typeof a === 'object' && 'b' in a) {
a.b;
}
};
Give the following error message
Property 'b' does not exist on type 'object'.
?
Edit: After looking into this more closely I have an even more minimal example. So let me rephrase my question:
How to probably narrow object
type in TypeScript?
tl;dr why does
const func = (a: object) => {
if ('b' in a) {
a.b;
}
give the following error message:
Property 'b' does not exist on type 'object'.
?