Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
fix(eslint-plugin): [no-unnecessary-type-parameters] descend into all parts of mapped types in no-unnecessary-type-parameters#9530
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thanks for the PR,@danvk! 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 onhttps://opencollective.com/typescript-eslint. |
netlifybot commentedJul 9, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview fortypescript-eslint ready!
To edit notification comments on pull requests, go to yourNetlify site configuration. |
nx-cloudbot commentedJul 9, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
☁️ Nx Cloud ReportCI is running/has finished running commands for commit9af9db6. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 fromNxCloud. |
codecovbot commentedJul 9, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@## main #9530 +/- ##======================================= Coverage 88.37% 88.37% ======================================= Files 419 419 Lines 14618 14621 +3 Branches 4279 4280 +1 =======================================+ Hits 12919 12922 +3 Misses 1375 1375 Partials 324 324
Flags with carried forward coverage won't be shown.Click here to find out more.
|
Incidentally@JoshuaKGoldberg I'm not sure why the new test case doesn't trigger the "quick path:" typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-parameters.ts Lines 59 to 63 inbebbd0c
declarefunctionmapObj<Kextendsstring,V,// Type parameter V is used only once>(obj:{[keyinK]:V},fn:(key:K,val:V)=>number,):number[]; I would have expected it to contain the references. |
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM, thanks for the fast follow! ⚡
Just requesting changes on a bit of testing. This basically an approval otherwise.
packages/eslint-plugin/tests/rules/no-unnecessary-type-parameters.test.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This should be good to go. I have no idea what the "Semantic Breaking Change PR / Validate Breaking Change PR (pull_request_target)" is about, and theerror logs aren't illuminating:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Beautiful, thanks! 🙌
10f8a4d
intotypescript-eslint:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
PR Checklist
Overview
Mapped types have three parts: the type parameter, the template type and the constraint type:
The rule previously descended into the typeParameter. It doesn't need to descend into the constraintType because we get that through another code path. It does need to descend into the templateType, though.
One wrinkle is that if the mapped type is something like
{[k in 'a']: T}
, then TypeScript will treat it like{a: T}
and we'll process it as an object type. In this case, we need to avoidalso processing it as a mapped type, even thoughisMappedType
returns true.