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(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
fix(typescript-estree): ensure consistent TSMappedType AST shape#11086
Conversation
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. |
netlifybot commentedApr 17, 2025 • 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 commentedApr 17, 2025 • 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.
View yourCI Pipeline Execution ↗ for commit656a3f9.
☁️Nx Cloud last updated this comment at |
readonly: node.readonlyToken | ||
?node.readonlyToken.kind === SyntaxKind.ReadonlyKeyword || | ||
getTextForTokenKind(node.readonlyToken.kind) | ||
: undefined, |
JoshuaKGoldbergMay 2, 2025 • 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.
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.
Note that
readonly
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
.
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.
🙌 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', () => { |
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.
[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.
codecovbot commentedMay 2, 2025 • 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 ReportAttention: Patch coverage is
❌ 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
Flags with carried forward coverage won't be shown.Click here to find out more.
🚀 New features to boost your workflow:
|
3c36704
to6a655f2
Compare6a655f2
to76f693f
CompareThere 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.
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!
@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? |
#6116 strikes again! We can ignore the coverage drop in this PR. |
4a97721
intotypescript-eslint:mainUh oh!
There was an error while loading.Please reload this page.
PR Checklist
Overview
Example a:
{ [k in any]: any }
Example b:
{ [k in any]?: any }
Example c:
{ readonly [k in any]: any }
Example d:
{ +readonly [k in any]?: any }
Example e:
{ -readonly [k in any]: any }