Is there a consistent way to test for undefined and null in typescript 2.0?

时间:2017-04-24 17:21:33

标签: typescript2.0

So, I have several checks like this in my code:

if (callerParam != undefined || callerParam != null)

I now upgraded to Typescript 2.0 and Visual Studio is telling 'Cannot resolve symbol 'undefined''.

But the compare to null is just fine.

So I guess I can go change all my compares to be like this:

if (typeof callerParam !== 'undefined' || callerParam != null)

and the intellisense is OK with that.

But it seems inconsistent.

Is there a way to get my consistant, happy, world back?

And, why is undefined not valid anymore? And yet it is valid javascript right?

0 个答案:

没有答案