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

fix(eslint-plugin): [no-unnecessary-type-assertion] handle assignment #3133

Merged
merged 1 commit into from Mar 8, 2021

Conversation

Zzzen
Copy link
Contributor

@Zzzen Zzzen commented Mar 2, 2021

should fix #2953

This is an aggressive move, but I don't why we don't use getContextualType directly. All current tests have passed. If this is feasible, I can add more test cases.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @Zzzen!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@Zzzen
Copy link
Contributor Author

Zzzen commented Mar 2, 2021

It is weird CI is failing to install dependencies.

@armano2
Copy link
Member

armano2 commented Mar 2, 2021

this error is unrelated to your change

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

The getContextualType function was first added in #478 (and was moved to a shared util in #1644).

I'll be honest when I say that I don't remember why I added it - I vaguely remember that there were a number of issues with getContextualType.
The fact that there's a lint error now that you've removed this logic says that it's still the case that checker.getContextualType is not infallible.

Please augment the logic instead of removing it.

@bradzacher bradzacher added the bug Something isn't working label Mar 2, 2021
@bradzacher bradzacher changed the title feat(eslint-plugin): [no-unnecessary-type-assertion] use getContextualType directly fix(eslint-plugin): [no-unnecessary-type-assertion] use getContextualType directly Mar 2, 2021
@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Mar 2, 2021
@Zzzen
Copy link
Contributor Author

Zzzen commented Mar 3, 2021

👌 👌 got it

@Zzzen Zzzen changed the title fix(eslint-plugin): [no-unnecessary-type-assertion] use getContextualType directly fix(eslint-plugin): [no-unnecessary-type-assertion] handle assignment Mar 4, 2021
@codecov
Copy link

codecov bot commented Mar 4, 2021

Codecov Report

Merging #3133 (de87f17) into master (9323eae) will decrease coverage by 0.01%.
The diff coverage is 77.77%.

@@            Coverage Diff             @@
##           master    #3133      +/-   ##
==========================================
- Coverage   92.88%   92.86%   -0.02%     
==========================================
  Files         315      315              
  Lines       10706    10715       +9     
  Branches     3025     3030       +5     
==========================================
+ Hits         9944     9951       +7     
  Misses        342      342              
- Partials      420      422       +2     
Flag Coverage Δ
unittest 92.86% <77.77%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...-plugin/src/rules/no-unnecessary-type-assertion.ts 94.66% <66.66%> (-2.44%) ⬇️
packages/eslint-plugin/src/util/types.ts 83.51% <100.00%> (+0.27%) ⬆️

@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Mar 4, 2021
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for your contribution!

@bradzacher bradzacher merged commit cb22561 into typescript-eslint:master Mar 8, 2021
This was referenced Mar 8, 2021
This was referenced Mar 15, 2021
@bradzacher
Copy link
Member

@danielrentz please file a new issue instead of commenting on old PRs.

@typescript-eslint typescript-eslint locked and limited conversation to collaborators Mar 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
4 participants