Suggestion: treat null and undefined as the same in strictNullChecks mode #13166
Labels
Declined
The issue was declined as something which matches the TypeScript vision
Suggestion
An idea for TypeScript
TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)
2.1.4
Suggestion
Sometimes we want to enable
strictNullChecks
, becausenull
will always with exception, which would interupt our program.But always people just want to make sure if a variable have been assigned.
For example:
In another hands, we may really don't care whether a variable without value is
null
orundefined
.While
strictNullChecks
treatnull
andundefined
differently.It bring some inconvenience, like:
or
So if we want to use
strictNullChecks
to check value have been assigned a value, we may have to:XXX | null | undefined
| null
or| undefined
Maybe at most time we want to treat
null
andundefined
as the same.So maybe better if there would be an option to achieve that.
The text was updated successfully, but these errors were encountered: