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(typescript-estree): ensure consistent TSMappedType AST shape#11086

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

Conversation

dbarabashh
Copy link
Contributor

PR Checklist

Overview

vara:{[kinany]:any}// No modifiersvarb:{[kinany]?:any}// Optional modifiervarc:{readonly[kinany]:any}// Readonly modifiervard:{+readonly[kinany]?:any}// +readonly and optional modifiervare:{-readonly[kinany]:any}// -readonly modifier

Example a:{ [k in any]: any }

{type:"TSMappedType",constraint:{type:"TSAnyKeyword"},key:{type:"Identifier",name:"k"},nameType:null,optional:false,// Now has explicit false valuereadonly:undefined,// Now has explicit undefined valuetypeAnnotation:{type:"TSAnyKeyword"}}

Example b:{ [k in any]?: any }

{type:"TSMappedType",constraint:{type:"TSAnyKeyword"},key:{type:"Identifier",name:"k"},nameType:null,optional:true,// Has true value because of ? modifierreadonly:undefined,// Now has explicit undefined valuetypeAnnotation:{type:"TSAnyKeyword"}}

Example c:{ readonly [k in any]: any }

{type:"TSMappedType",constraint:{type:"TSAnyKeyword"},key:{type:"Identifier",name:"k"},nameType:null,optional:false,// Now has explicit false valuereadonly:true,// Has true value because of readonly modifiertypeAnnotation:{type:"TSAnyKeyword"}}

Example d:{ +readonly [k in any]?: any }

{type:"TSMappedType",constraint:{type:"TSAnyKeyword"},key:{type:"Identifier",name:"k"},nameType:null,optional:true,// Has true value because of ? modifierreadonly:"+",// Has "+" value because of +readonly modifiertypeAnnotation:{type:"TSAnyKeyword"}}

Example e:{ -readonly [k in any]: any }

{type:"TSMappedType",constraint:{type:"TSAnyKeyword"},key:{type:"Identifier",name:"k"},nameType:null,optional:false,// Now has explicit false valuereadonly:"-",// Has "-" value because of -readonly modifiertypeAnnotation:{type:"TSAnyKeyword"}}

JLHwung reacted with heart emoji
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@dbarabashh!

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 commentedApr 17, 2025
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit656a3f9
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/6818278fcd0dae0008550592
😎 Deploy Previewhttps://deploy-preview-11086--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: 99 (🟢 up 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (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 commentedApr 17, 2025
edited
Loading

View yourCI Pipeline Execution ↗ for commit656a3f9.

CommandStatusDurationResult
nx run-many --target=build --exclude website --...✅ Succeeded2sView ↗
nx run-many --target=clean✅ Succeeded10sView ↗

☁️Nx Cloud last updated this comment at2025-05-05 15:12:23 UTC

@dbarabashhdbarabashh changed the titlefix(typescript-estree): Inconsistent TSMappedType AST shapefix(typescript-estree): ensure consistent TSMappedType AST shapeApr 17, 2025
@dbarabashhdbarabashh changed the titlefix(typescript-estree): ensure consistent TSMappedType AST shapefix(eslint-plugin): ensure consistent TSMappedType AST shapeApr 18, 2025
readonly: node.readonlyToken
?node.readonlyToken.kind === SyntaxKind.ReadonlyKeyword ||
getTextForTokenKind(node.readonlyToken.kind)
: undefined,
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldbergMay 2, 2025
edited
Loading

Choose a reason for hiding this comment

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

Note thatreadonly is an enum oftrue,+ and-. So previously I proposedundefined as the default value. I guessfalse does no harm here.

Agreed that either could work, and also agreed on going withundefined. That feels to me like a more normal default when there are multiple truthy options ('+','-'). I can see whyfalse might make sense as a counterpoint totrue, but visually I think it makes less sense thanundefined.

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.

🙌 The source code change looks good to me, thanks! Requesting changes on going with the ast-spec tests that other types of syntax conversions are verified with too.

@@ -449,5 +449,79 @@ describe('convert', () => {
expect(tsMappedType.typeParameter).toBeUndefined();
expect(Object.keys(tsMappedType)).toContain('typeParameter');
});

describe('TSMappedType AST shape consistency', () => {

Choose a reason for hiding this comment

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

[Testing] We normally put fixtures inpackages/ast-spec/src. Is there a reason not to here?

If not, I thinkpackages/ast-spec/src/type/TSMappedType would be the right place to add new fixtures aroundreadonly and/or optional mapped types.

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelMay 2, 2025
@codecovCodecov
Copy link

codecovbot commentedMay 2, 2025
edited
Loading

Codecov Report

Attention: Patch coverage is25.00000% with6 lines in your changes missing coverage. Please review.

Project coverage is 90.84%. Comparing base(f30a20e) to head(656a3f9).
Report is 19 commits behind head on main.

Files with missing linesPatch %Lines
packages/typescript-estree/src/convert.ts25.00%6 Missing⚠️

❌ Your patch status has failed because the patch coverage (25.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust thetarget coverage.

Additional details and impacted files
@@            Coverage Diff             @@##             main   #11086      +/-   ##==========================================+ Coverage   90.82%   90.84%   +0.01%==========================================  Files         497      497                Lines       50204    50320     +116       Branches     8274     8311      +37     ==========================================+ Hits        45600    45714     +114- Misses       4589     4591       +2  Partials       15       15
FlagCoverage Δ
unittest90.84% <25.00%> (+0.01%)⬆️

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

Files with missing linesCoverage Δ
packages/typescript-estree/src/convert.ts30.74% <25.00%> (ø)

... and7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelMay 5, 2025
@bradzacherbradzacherforce-pushed thefix/ast-tsmappedtype-shape branch from3c36704 to6a655f2CompareMay 5, 2025 02:45
@bradzacherbradzacherforce-pushed thefix/ast-tsmappedtype-shape branch from6a655f2 to76f693fCompareMay 5, 2025 02:45
Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

thanks -- just because my review time is limited I took a moment to fix up your fixtures (you had nested the folders incorrectly which meant the snapshots weren't generated -- we might wanna add an error for this...). And I added a few extra snapshots to cover some more cases.

this all LGTM!

@bradzacherbradzacher added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelMay 5, 2025
@dbarabashh
Copy link
ContributorAuthor

@bradzacher Thank you so much. I was just about to write a comment about the file structure.

and one more question, what should we do about the coverage rate?

@JoshuaKGoldbergJoshuaKGoldberg changed the titlefix(eslint-plugin): ensure consistent TSMappedType AST shapefix(typescript-estree): ensure consistent TSMappedType AST shapeMay 5, 2025
@JoshuaKGoldberg
Copy link
Member

coverage rate

#6116 strikes again! We can ignore the coverage drop in this PR.

@JoshuaKGoldbergJoshuaKGoldberg merged commit4a97721 intotypescript-eslint:mainMay 5, 2025
60 of 61 checks passed
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsMay 13, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@bradzacherbradzacherbradzacher approved these changes

@JoshuaKGoldbergJoshuaKGoldbergAwaiting requested review from JoshuaKGoldberg

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: Inconsistent TSMappedType AST shape for optional and readonly
3 participants
@dbarabashh@JoshuaKGoldberg@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp