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

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

Merged
bradzacher merged 6 commits intotypescript-eslint:mainfromdanvk:fix-9524
Jul 14, 2024

Conversation

danvk
Copy link
Collaborator

@danvkdanvk commentedJul 9, 2024
edited by kirkwaiblinger
Loading

PR Checklist

Overview

Mapped types have three parts: the type parameter, the template type and the constraint type:

> type.checker.typeToString(type)'{ [key in K]?: V | undefined; }'> type.checker.typeToString(type.typeParameter)'key'> type.checker.typeToString(type.templateType)'V | undefined'> type.checker.typeToString(type.constraintType)'K'

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.

@typescript-eslint
Copy link
Contributor

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.

@netlifyNetlify
Copy link

netlifybot commentedJul 9, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit9af9db6
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/668eba0fde1687000806398b
😎 Deploy Previewhttps://deploy-preview-9530--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 95 (🔴 down 3 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to yourNetlify site configuration.

@nx-cloudNx Cloud
Copy link

nx-cloudbot commentedJul 9, 2024
edited
Loading

☁️ Nx Cloud Report

CI 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 target

Sent with 💌 fromNxCloud.

@codecovCodecov
Copy link

codecovbot commentedJul 9, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.37%. Comparing base(0d4b098) to head(9af9db6).
Report is 1 commits behind head on main.

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
FlagCoverage Δ
unittest88.37% <100.00%> (+<0.01%)⬆️

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

FilesCoverage Δ
...plugin/src/rules/no-unnecessary-type-parameters.ts96.21% <100.00%> (+0.08%)⬆️

@danvk
Copy link
CollaboratorAuthor

Incidentally@JoshuaKGoldberg I'm not sure why the new test case doesn't trigger the "quick path:"

// Quick path: if the type parameter is used multiple times in the AST,
// we don't need to dip into types to know it's repeated.
if(isTypeParameterRepeatedInAST(esTypeParameter,scope.references)){
continue;
}

scope.references is empty for bothK andV in:

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.

Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg 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 the fast follow! ⚡

Just requesting changes on a bit of testing. This basically an approval otherwise.

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelJul 10, 2024
@danvk
Copy link
CollaboratorAuthor

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:

Error: Cannot find module '@actions/core'

@JoshuaKGoldberg
Copy link
Member

oop#9533@auvred - looks like they were necessary after all?

We can ignore them in this PR.

Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Beautiful, thanks! 🙌

@auvred
Copy link
Member

oop#9533@auvred - looks like they were necessary after all?

My bad, sorry 😬

#9535

@JoshuaKGoldbergJoshuaKGoldberg added 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge and removed awaiting responseIssues waiting for a reply from the OP or another party labelsJul 10, 2024
@bradzacherbradzacher changed the titlefix: descend into all parts of mapped types in no-unnecessary-type-parametersfix(eslint-plugin): [no-unnecessary-type-parameters] descend into all parts of mapped types in no-unnecessary-type-parametersJul 14, 2024
@bradzacherbradzacher merged commit10f8a4d intotypescript-eslint:mainJul 14, 2024
66 of 70 checks passed
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJul 24, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@jakebaileyjakebaileyjakebailey left review comments

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg approved these changes

@bradzacherbradzacherbradzacher approved these changes

Assignees
No one assigned
Labels
1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Bug: [no-unnecessary-type-parameters] double false positive
5 participants
@danvk@JoshuaKGoldberg@auvred@jakebailey@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp