Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(eslint-plugin): Contextual non-null [no-unnecessary-type-assertion]#478

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 3 commits intomasterfrommore-unnecessary-assertion
May 9, 2019

Conversation

bradzacher
Copy link
Member

Fix handling of "used before assigned" variables:
Fixes#453

Note: this fix isn't perfect, but it's "good enough".
The type checker exposes no mechanism to detect this case (but it has code for it:https://raw.githubusercontent.com/Microsoft/TypeScript/84076a55351684296f7b3f1d2715690acbe8039f/src/compiler/checker.ts and search forVariable_0_is_used_before_being_assigned)

See:microsoft/TypeScript#31124 andmicrosoft/TypeScript#20221


Also adds handling for contextually unnecessary non-null operator based on where it's used:

declare function nonNull(s: string | null);let s: string | null = null;nonNull(s!); // contextually unnecessary, as function accepts the same type

Will look at adding contextually unnecessary support to theas branch later - this PR is big enough as is...

@bradzacherbradzacher added the enhancementNew feature or request labelApr 26, 2019
@codecov
Copy link

codecovbot commentedMay 9, 2019

Codecov Report

Merging#478 intomaster willdecrease coverage by0.14%.
The diff coverage is85.91%.

@@            Coverage Diff             @@##           master     #478      +/-   ##==========================================- Coverage   95.88%   95.73%   -0.15%==========================================  Files          79       79                Lines        3571     3613      +42       Branches      998     1013      +15     ==========================================+ Hits         3424     3459      +35- Misses         51       53       +2- Partials       96      101       +5
Impacted FilesCoverage Δ
...ges/eslint-plugin/src/rules/no-extraneous-class.ts100% <100%> (ø)⬆️
packages/eslint-plugin/src/rules/member-naming.ts100% <100%> (ø)⬆️
packages/eslint-plugin/src/util/types.ts73.33% <77.77%> (+10.83%)⬆️
...-plugin/src/rules/no-unnecessary-type-assertion.ts91.17% <87.23%> (-6.5%)⬇️

@bradzacherbradzacher merged commit4cd5590 intomasterMay 9, 2019
@bradzacherbradzacher deleted the more-unnecessary-assertion branchMay 9, 2019 16:32
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsApr 21, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@JamesHenryJamesHenryJamesHenry approved these changes

Assignees
No one assigned
Labels
enhancementNew feature or request
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[no-unnecessary-type-assertion] false positive on uninitialized variables
2 participants
@bradzacher@JamesHenry

[8]ページ先頭

©2009-2025 Movatter.jp