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 compatibility between estree and TS plugin #9700

Merged
merged 1 commit into from Mar 23, 2019
Merged

Fix compatibility between estree and TS plugin #9700

merged 1 commit into from Mar 23, 2019

Conversation

danez
Copy link
Member

@danez danez commented Mar 18, 2019

Q                       A
Fixed Issues? Fixes #9228
Patch: Bug Fix? y
Major: Breaking Change? y
Minor: New Feature? n
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This modifies the typescript plugin to parse literals in a way that the estree plugin can correctly convert them.

This also has one breaking changes:

type x = -1;

This was parsed as

TSTypeAliasDeclaration -> TSLiteralType -> NumericLiteral (value = -1)

now it is

TSTypeAliasDeclaration -> TSLiteralType -> UnaryExpression(operator=-) -> NumericLiteral (value = 1)

To me this was simply wrong because estree never defines numeric literals with negative values and we nowhere do this for the BabelLiterals. Not sure if this would be okay to go into a minor version. For what it's worth typescript and eslint-typescript also parses it this way.

@danez danez added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: parser area: typescript labels Mar 18, 2019
@babel-bot
Copy link
Collaborator

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

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.

I don't think that the - change will cause any problem, especially since this was the only place where we didn't parse -1 as two different nodes.

@danez danez merged commit ef0722b into babel:master Mar 23, 2019
@danez danez deleted the fix-9228 branch March 23, 2019 23:47
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
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: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typescript: is not converting BooleanLiteral in types with [plugin, estree]
4 participants