Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ast-spec): remove more invalid properties #6243

Conversation

JoshuaKGoldberg
Copy link
Member

BREAKING CHANGE:
Removes properties from ast-spec and therefore typescript-estree

PR Checklist

Overview

Removes the additional properties listed by @bradzacher in #4759.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

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 on https://opencollective.com/typescript-eslint.

@nx-cloud
Copy link

nx-cloud bot commented Dec 17, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 03b54f7. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review December 18, 2022 02:17
@JoshuaKGoldberg JoshuaKGoldberg added this to the 6.0.0 milestone Dec 18, 2022
@bradzacher bradzacher added bug Something isn't working breaking change This change will require a new major version to be released labels Jan 30, 2023
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

anakin_delete

@@ -8,26 +8,6 @@ Object {
"body": Array [
Object {
"computed": false,
"export": undefined,
"initializer": Object {
Copy link
Member

Choose a reason for hiding this comment

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

hmm - i wonder if we should throw on this specific case?
prettier currently supports it, but other parsers (babel) throw here.

If we don't throw, I believe prettier will just delete the code silently when it formats.
WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@bradzacher @fisker I went ahead and added errors for the other @deprecated node properties in typescript.d.ts (TIL!):

interface PropertySignature {
    /** @deprecated A property signature cannot have an initializer */
    readonly initializer?: Expression | undefined;
}
interface PropertyAssignment {
    /** @deprecated A property assignment cannot have a question token */
    readonly questionToken?: QuestionToken | undefined;
    /** @deprecated A property assignment cannot have an exclamation token */
    readonly exclamationToken?: ExclamationToken | undefined;
}
interface ShorthandPropertyAssignment {
    /** @deprecated A shorthand property assignment cannot have modifiers */
    readonly modifiers?: NodeArray<Modifier> | undefined;
    /** @deprecated A shorthand property assignment cannot have a question token */
    readonly questionToken?: QuestionToken | undefined;
    /** @deprecated A shorthand property assignment cannot have an exclamation token */
    readonly exclamationToken?: ExclamationToken | undefined;
}
interface FunctionTypeNode {
    /** @deprecated A function type cannot have modifiers */
    readonly modifiers?: NodeArray<Modifier> | undefined;
}

d3c054f

Do you think this is reasonable for Prettier too? I'd be interested in sending a PR over if so, I haven't actually contributed to Prettier yet!

Copy link
Contributor

Choose a reason for hiding this comment

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

Great! Saving us from checking those.

Copy link
Member Author

Choose a reason for hiding this comment

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

@fisker I poked around in Prettier-land and couldn't figure out if there was anything else for me to change there. I'll defer to you. If you end up filing an issue in Prettier I'd love to tackle it. But it's a bit much for me on my own. 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@bradzacher
Copy link
Member

cc @fisker / @sosukesuzuki for the prettier POV.

We're removing bits of the AST that shouldn't be there in our next major. All the things we are removing are bad code that should probably be syntax errors, but aren't for because #just-ts-things.

From prettier's POV - would it be better if:
a) we explicitly throw if they're there so that you don't remove them during formatting (because you can't format!)
b) we don't error and the obviously bad, no-op bits of code just disappear during formatting?
c) we don't error, and you look up the info on the TS-AST if you want to keep it during printing.
d) we error and provide a flag that allows us to not error so you can go route (c).

WDYT?

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Jan 30, 2023
@fisker
Copy link
Contributor

fisker commented Jan 30, 2023

We already check lot's of errors in our next branch, so we can test those properties, it doesn't really matter.

It will be nice to throw errors here, I choose c).

Anyway, it's always good to have a choice, so if not much trouble d) is best for now (we may still need release Prettier 2.x), but after Prettier v3, we definitely don't want hide syntax errors.

Copy link
Contributor

@fisker fisker left a comment

Choose a reason for hiding this comment

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

Let's kill them ALL!

@fisker

This comment was marked as outdated.

@bradzacher
Copy link
Member

@JoshuaKGoldberg I think we need to be a little stricter here and explicitly error if we encounter this weird bit of syntax.

The issue with just ignoring it is that it'll potentially have downstream effects on ESLint fixers that act on raw source code and could lead to a fixer introducing a syntax error.

@codecov
Copy link

codecov bot commented Feb 5, 2023

Codecov Report

Merging #6243 (03b54f7) into v6 (3915661) will decrease coverage by 0.06%.
The diff coverage is 18.75%.

Additional details and impacted files
@@            Coverage Diff             @@
##               v6    #6243      +/-   ##
==========================================
- Coverage   87.15%   87.10%   -0.06%     
==========================================
  Files         362      362              
  Lines       12459    12470      +11     
  Branches     3688     3688              
==========================================
+ Hits        10859    10862       +3     
- Misses       1253     1261       +8     
  Partials      347      347              
Flag Coverage Δ
unittest 87.10% <18.75%> (-0.06%) ⬇️

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

Impacted Files Coverage Δ
packages/visitor-keys/src/visitor-keys.ts 100.00% <ø> (ø)
packages/typescript-estree/src/convert.ts 28.68% <18.75%> (-0.03%) ⬇️

@JoshuaKGoldberg JoshuaKGoldberg removed the awaiting response Issues waiting for a reply from the OP or another party label Feb 5, 2023
@bradzacher bradzacher added the 1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready label Feb 13, 2023
@JoshuaKGoldberg JoshuaKGoldberg merged commit aa20f63 into typescript-eslint:v6 Feb 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready breaking change This change will require a new major version to be released bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants