Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tsconfig): use strict null checks #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

geraldalewis
Copy link
Collaborator

By default, TS considers null and undefined to be members of
every type. This does not match the semantics of EcmaScript and
requires devs to sprinkle lots of null and undefined guards
throughout the code. This update fixes that.

deep dive
ts docs

For an example in our own codebase, see https://github.com/mojotech/pt-estimator/pull/25/files#diff-21fb8fb9e023edf58649b90783831bedR48

By default, TS considers `null` and `undefined` to be members of
_every_ type. This does not match the semantics of EcmaScript and
requires devs to sprinkle lots of `null` and `undefined` guards
throughout the code. This update fixes that.
event.preventDefault();
setToken(tokenRef.current.value);
setToken(tokenRef.current!.value);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Usually the assertion operator is not the right choice, but we want a noisy failure here in the highly improbable event that tokenRef.current is null.

Copy link
Contributor

@mariana0pachon mariana0pachon left a comment

Choose a reason for hiding this comment

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

Needs a rebase but then I think it looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants