Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[babel 8] Use an identifier for TSTypeParameter.name#12829

Merged
nicolo-ribaudo merged 9 commits intobabel:mainfrom
fedeci:tstypeparameter-name-identifier
Jul 2, 2021
Merged

[babel 8] Use an identifier for TSTypeParameter.name#12829
nicolo-ribaudo merged 9 commits intobabel:mainfrom
fedeci:tstypeparameter-name-identifier

Conversation

@fedeci
Copy link
Member

@fedeci fedeci commented Feb 19, 2021

Q                       A
Fixed Issues? Fixes #12825
Patch: Bug Fix?
Major: Breaking Change? Yes, under BABEL_8_BREAKING and BABEL_TYPES_8_BREAKING
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link babel/website#2765
Any Dependency Changes?
License MIT

We parse the entire identifier if BABEL_8_BREAKING otherwise we parse just his name.

@babel-bot
Copy link
Collaborator

babel-bot commented Feb 19, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/47144/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 19, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c689678:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

Comment on lines +963 to +964
name: string,
typeName: Identifier,
Copy link
Member Author

@fedeci fedeci Feb 19, 2021

Choose a reason for hiding this comment

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

We can also handle this as a union type assigning it under the BABEL_8_BREAKING flag.
(Typescript is using name and not typeName for TypeParameter)

Suggested change
name: string,
typeName: Identifier,
name: string | Identifier,

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo 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 just do this for Babel 8 (BABEL_8_BREAKING).

This PR as-is is problematic because it introduces two different source of truth in the AST, and modifying typeName in a plugin doesn't have any effect on the generated code.

@fedeci fedeci force-pushed the tstypeparameter-name-identifier branch from afadd08 to a91f51e Compare March 7, 2021 13:49
@fedeci fedeci marked this pull request as draft March 7, 2021 14:47
@fedeci fedeci force-pushed the tstypeparameter-name-identifier branch from a91f51e to 0325e76 Compare March 8, 2021 07:50
@fedeci
Copy link
Member Author

fedeci commented Mar 8, 2021

Those ~30 errors are all related to babel-parser fixtures that need to be updated. Is there a way to avoid duplicating them?

@fedeci fedeci force-pushed the tstypeparameter-name-identifier branch from d0d5af4 to 80ca25f Compare March 8, 2021 20:04
@nicolo-ribaudo
Copy link
Member

Those ~30 errors are all related to babel-parser fixtures that need to be updated. Is there a way to avoid duplicating them?

You need to duplicate them, rename the copy as ...-babel-7, and add BABEL_8_BREAKING: true and BABEL_8_BREAKING: false to the test options.

@fedeci
Copy link
Member Author

fedeci commented Mar 9, 2021

It's huge

@nicolo-ribaudo nicolo-ribaudo changed the title feat(ts): add typeName property to TSTypeParameter [babel 8] Use an identifier for TSTypeReference.typeName Mar 9, 2021
@fedeci fedeci marked this pull request as ready for review March 21, 2021 10:59
@fedeci fedeci force-pushed the tstypeparameter-name-identifier branch from d99778f to d5610d0 Compare June 26, 2021 16:45
@fedeci fedeci force-pushed the tstypeparameter-name-identifier branch from d5610d0 to 77951da Compare June 26, 2021 17:01
@nicolo-ribaudo
Copy link
Member

I re-approved because I'm not sure about what changed since my last review, but I reviewed it again.

@fedeci
Copy link
Member Author

fedeci commented Jun 29, 2021

Just wait to merge this that I have to update TypeParameter also.
Since Flow parses TypeParameters.name as a string we don't have to change that behaviour. I decided to remove TypeParameterBase instead so that we can handle the two different cases separately.

@fedeci fedeci changed the title [babel 8] Use an identifier for TSTypeReference.typeName [babel 8] Use an identifier for TSTypeParameter.name Jun 29, 2021
@nicolo-ribaudo
Copy link
Member

Since Flow parses TypeParameters.name as a string we don't have to change that behaviour.

We might still decide that it's better to align our Flow implementation with our TS implementation, rather than aligning it with the Flow AST. However, that's a separate discussion and let's keep this PR only for TS.

@nicolo-ribaudo nicolo-ribaudo merged commit 9bad558 into babel:main Jul 2, 2021
@JLHwung JLHwung mentioned this pull request Jul 2, 2021
34 tasks
@fedeci fedeci deleted the tstypeparameter-name-identifier branch July 3, 2021 11:26
@JLHwung JLHwung mentioned this pull request Jul 7, 2021
nicolo-ribaudo pushed a commit to nicolo-ribaudo/babel that referenced this pull request Jul 30, 2021
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2021
@nicolo-ribaudo nicolo-ribaudo added this to the v8.0.0 milestone Aug 8, 2023
@nicolo-ribaudo nicolo-ribaudo added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release and removed babel 8 labels Aug 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: typescript outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parser(ts): TSTypeParameter name should be an Identifier

4 participants