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

feat(typescript-estree): restrict variable declarator definite/init combinations#9228

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

Conversation

@Josh-Cena
Copy link
Member

PR Checklist

Overview

I added A LOT of fixtures (programmatically of course) and I noticed that Babel didn't give some errors while IMO they should.

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@Josh-Cena!

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.

@netlify
Copy link

netlifybot commentedJun 3, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitbe1b324
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/66b8181951c1680008e2042f
😎 Deploy Previewhttps://deploy-preview-9228--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 4 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-cloud
Copy link

nx-cloudbot commentedJun 3, 2024
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commitbe1b324. 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 2 targets

Sent with 💌 fromNxCloud.

@Josh-CenaJosh-Cenaforce-pushed thevar-decl-ast-invariant branch from16faace tocea3f68CompareJune 3, 2024 15:26
Copy link
MemberAuthor

@Josh-CenaJosh-CenaJun 3, 2024
edited
Loading

Choose a reason for hiding this comment

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

Script for generating this pile of fixtures. Let me know if I should trim it down (especially the error combinations)

Copy link
Member

Choose a reason for hiding this comment

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

Nit: I wouldn't bother committing this - just leaving it as a note in the PR description should be enough for us to find it later if we want to reproduce this later.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Ok but I designed this script to allow us to:

  • Quickly identify error condition combinations
  • Quickly move a bunch of fixtures around valid/invalid cases
  • Quickly generate more combinations,

so I think overall it helps with maintenance

Comment on lines +20 to +27
"declaration/VariableDeclaration/fixtures/_error_/const-destructure-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/const-destructure-type-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/const-id-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/const-id-type-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/let-destructure-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/let-destructure-type-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/var-destructure-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/var-destructure-type-no-init/fixture.ts",
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

These are because we don't have the ability to detect whether a declaration is in an ambient context unless itself hasdeclare

Comment on lines +59 to +75
"declaration/VariableDeclaration/fixtures/_error_/const-id-definite-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/const-id-definite-type-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/declare-const-id-definite-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/declare-const-id-definite-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/declare-const-id-definite-type-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/declare-let-id-definite-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/declare-let-id-definite-type-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/declare-var-id-definite-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/declare-var-id-definite-type-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/let-id-definite-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/let-id-definite-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/let-id-definite-type-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/using-id-definite-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/using-id-definite-type-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/var-id-definite-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/var-id-definite-no-init/fixture.ts",
"declaration/VariableDeclaration/fixtures/_error_/var-id-definite-type-init/fixture.ts",
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Babel doesn't detect whether a definite assignment is put on a non-declared let/var with type and no init. This is arguably a Babel bug

@bradzacherbradzacher added the ASTPRs and Issues about the AST structure labelJun 4, 2024
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I wouldn't bother committing this - just leaving it as a note in the PR description should be enough for us to find it later if we want to reproduce this later.

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelJun 17, 2024
@JoshuaKGoldberg
Copy link
Member

👋@Josh-Cena did you mean to re-request review on this?

@Josh-Cena
Copy link
MemberAuthor

I actually don't remember where the discussion left off. But yeah@bradzacher I think another look is worthwhile. I still want to keep the fixture generation script.

@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelJul 12, 2024
bradzacher
bradzacher previously approved these changesJul 12, 2024
Copy link
Member

@bradzacherbradzacher left a comment
edited
Loading

Choose a reason for hiding this comment

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

I can't see one - could you please add an error fixture for

for(usingx!of[]){}

Other than that - looking fantastic!
We can land once you've got that!

@bradzacherbradzacher added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelJul 12, 2024
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.

Can we also add this

interfaceVariableDeclarator{parent:VariableDeclaration;}

tohttps://github.com/typescript-eslint/typescript-eslint/blob/main/packages/types/src/ts-estree.ts for#6225

@Josh-Cena
Copy link
MemberAuthor

Will come back to it next week...!

@Josh-Cena
Copy link
MemberAuthor

@bradzacher: unfortunately,VariableDeclarator is no longer an interface, but a union, so we can no longer merge it. If we really want to, we have to mergeparent into individual constituents. Does that sound fine?

@codecov
Copy link

codecovbot commentedJul 19, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.27%. Comparing base(07700dd) to head(d765c76).

Current headd765c76 differs from pull request most recent headbe1b324

Pleaseupload reports for the commitbe1b324 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@##             main    #9228      +/-   ##==========================================+ Coverage   88.07%   88.27%   +0.20%==========================================  Files         402      422      +20       Lines       13693    14679     +986       Branches     3982     4299     +317     ==========================================+ Hits        12060    12958     +898- Misses       1324     1400      +76- Partials      309      321      +12
FlagCoverage Δ
unittest88.27% <ø> (+0.20%)⬆️

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

see 115 files with indirect coverage changes

@bradzacher
Copy link
Member

Yeah that's perfectly fine - if you have a look at the file you'll see that's the common pattern.

Eventually we'll just want to addparent to the AST and merge the file into the main ast.

@bradzacher
Copy link
Member

Screenshot_20240720-110239.png github ffs

Me, trying to review this PR.
Ffs github

Josh-Cena reacted with laugh emoji

bradzacher
bradzacher previously approved these changesJul 20, 2024
@bradzacher
Copy link
Member

Most of the other ast changes have gone into v8 - do we want to also merge this into v8 as well to avoid the inevitable merge conflicts?

@Josh-Cena
Copy link
MemberAuthor

Mmmm, that's a good point, although other AST changes I sent have already gone into main.

@JoshuaKGoldbergJoshuaKGoldberg removed the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelJul 29, 2024
@Josh-Cena
Copy link
MemberAuthor

Oof, I didn't realize this PR is still unmerged. I've resolved the conflicts.

@bradzacherbradzacher merged commita4992ff intotypescript-eslint:mainAug 11, 2024
@Josh-CenaJosh-Cena deleted the var-decl-ast-invariant branchAugust 11, 2024 03:35
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsAug 19, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@bradzacherbradzacherbradzacher approved these changes

Assignees

No one assigned

Labels

ASTPRs and Issues about the AST structure

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AST tightening: around init/definite combinations on let/var/const declarators

3 participants

@Josh-Cena@JoshuaKGoldberg@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp