-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Rule proposal: Prefer non-null assertion operator over type assertion #202
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
Comments
this would probably be better suited being rolled into a rule like |
|
This PR changes logic behind `no-use-before-define` to traverse all scopes fixes: typescript-eslint#141
Now that Edit: oh, and while this technically does intersect with |
because this requires type information, I'd lean towards this being a new rule. |
Uh oh!
There was an error while loading. Please reload this page.
I have the following code:
Where
lookup
isnumber | undefined
.In this code path, I know for sure that
lookup
will be a number, so I have done the following:But a better solution would have been to use the non-null assertion operator:
I would like a rule that enforces this.
It should be noted in the rule docs that this conflicts with the
no-non-null-assertion
rule.Alternatively, the
no-non-null-assertion
could be renamed tonon-null-assertion
and handle both ways. That might be even better.The text was updated successfully, but these errors were encountered: