Skip to content

Enable strict null checking for common/uri common/map node/pfs and node/glob test#65488

Merged
bpasero merged 6 commits intomicrosoft:masterfrom
kerm1it:strict-null-check-node
Dec 20, 2018
Merged

Enable strict null checking for common/uri common/map node/pfs and node/glob test#65488
bpasero merged 6 commits intomicrosoft:masterfrom
kerm1it:strict-null-check-node

Conversation

@kerm1it
Copy link
Contributor

@kerm1it kerm1it commented Dec 20, 2018

#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"

@kerm1it kerm1it changed the title Enable strict null checking for node/pfs and node/glob test Enable strict null checking for common/uri common/map node/pfs and node/glob test Dec 20, 2018
@kerm1it kerm1it changed the title Enable strict null checking for common/uri common/map node/pfs and node/glob test Enable strict null checking for node/pfs and node/glob test Dec 20, 2018
@kerm1it kerm1it changed the title Enable strict null checking for node/pfs and node/glob test Enable strict null checking for common/uri common/map node/pfs and node/glob test Dec 20, 2018
@bpasero bpasero merged commit 5874ba8 into microsoft:master Dec 20, 2018
@bpasero bpasero added this to the December/January 2019 milestone Dec 20, 2018
const map = new Map<string, string>();
map.set('1', 'foo');
map.set('2', null);
map.set('2', null!);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does null! do? can't seem to wrap my head around it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ! ?

@kerm1it kerm1it deleted the strict-null-check-node branch December 20, 2018 15:49
@kerm1it kerm1it restored the strict-null-check-node branch December 20, 2018 15:49
@kerm1it kerm1it deleted the strict-null-check-node branch December 20, 2018 16:04
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants