Enable strict null checking for common/uri common/map node/pfs and node/glob test#65488
Enable strict null checking for common/uri common/map node/pfs and node/glob test#65488bpasero merged 6 commits intomicrosoft:masterfrom kerm1it:strict-null-check-node
Conversation
| const map = new Map<string, string>(); | ||
| map.set('1', 'foo'); | ||
| map.set('2', null); | ||
| map.set('2', null!); |
There was a problem hiding this comment.
what does null! do? can't seem to wrap my head around it
There was a problem hiding this comment.
Because of strict-null-check mode, the null and string are not in the domain of the same type. It will throw error when typescript compile with --strictNullChecks. You can know strict-null-check in the Typescript Doc.
There was a problem hiding this comment.
I understand the non null assertion operator generally, for example when used with objects, it indicates to the compiler that we are sure the object is not going to be null even if the compiler can't infer it.
i just don't understand why is it used with null here and what does it mean to the compiler in this case.
We are passing null to something which is not declared as nullable, and cheating the compiler by adding a ! ?
#65233
"./vs/base/test/node/uri.test.ts""./vs/base/test/node/map.test.ts""./vs/base/test/node/pfs.test.ts""./vs/base/test/node/glob.test.ts"