Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use strictNullChecks with libraries that are not nullCheck safe

I feel like I am missing something big here. I have read all the details of the new strictNullCheck goodness in typescript 2.0. I would love to use it but when I turn it on in my projects it finds issues with the supporting libraries I am using and their associated type definitions.

I can change my code to have sound type definitions but I don't have an easy way to update all the other libraries I use. Does this effectively mean that I can't use strictNullCheck until/unless the libraries I am using update to be strict null safe?

like image 898
Allen Avatar asked Sep 21 '16 15:09

Allen


People also ask

How do I disable strict null check?

Setting the option strictNullInputTypes to false disables strict null checks within Angular templates.

How do I enable strictNullChecks typescript?

To enable StrictNullChecks open tsconfg. sys and add "strictNullChecks": true under the compilerOptions . With this set to true , you'll get a type error if you try to use null or undefined wherever Typescript expects a concrete type.

How do you enforce a strict null check in typescript?

In Typescript to enforce strict null checks in tsconfig. json file, we need to enable “strictNullChecks” to true. When “strictNullChecks” is false, the language generally ignores variables of type null and undefined. If null and undefined is used in places where a definite value is expected, it raises an error.


1 Answers

After looking around for quite a while I finally found that by using the compiler option skipDefaultLibCheck you can get most of what I needed here.

like image 124
Allen Avatar answered Oct 14 '22 02:10

Allen