Post

`typeof null === 'object'` so I think you might need to check for null. And then I tend to find 'a' in x more reliable in TS

0 reposts0 likes

It's because the object type doesn't have a property called a. Using `in` will probably solve that like you said 👀

Right, I know how to work around it. But I am asking: Shouldn’t this be accepted by the type checker (because `null?.a` is perfectly valid)

That's just how the object type works in typescript. You're asserting it's an object and then trying to use it like `any` but it's not equivalent.