Why isn't TypeScript giving an error?
So I'm helping this person on another server and their code looks like the following:
When you run this, you will get an error of abbreviation isn't defined (for the shouldFail case)
It will return undefined if you provide the ? operator
zeroth?.abbreviation
as expected, but typescript doesn't give a linting error for it
Anyone know why?9 Replies
TS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
playground
code screenshot (no linting error)

Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
ah, that makes sense
I figured it was due to the nesting
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
so why wouldn't it still give a linting error on
zeroth.abbreviation
like it doesn't have a way of knowing that it isn't, but is also don't have a way of knowing that it is
I assume it's just some way that typescript works that I'm sort of missingUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
Sick thanks