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

TypeScript: Support parsing 'unique' type operator #7239

Merged
merged 1 commit into from Jan 22, 2018
Merged

TypeScript: Support parsing 'unique' type operator #7239

merged 1 commit into from Jan 22, 2018

Conversation

ghost
Copy link

@ghost ghost commented Jan 18, 2018

Q                       A
Fixed Issues?
Patch: Bug Fix? No
Major: Breaking Change? No
Minor: New Feature? Yes
Tests Added + Pass? Yes
Documentation PR
Any Dependency Changes? No
License MIT

microsoft/TypeScript#15473 added the unique keyword to the language. This adds support in babylon to parse it. There were no necessary changes to the generator, which already handles any keyword, or to the plugin, which erases all types without needing to look at their contents.
@rbuckton and @DanielRosenwasser for review.
See also eslint/typescript-eslint-parser#433, which does the same thing in their parser. @azz @JamesHenry

@babel-bot
Copy link
Collaborator

babel-bot commented Jan 18, 2018

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

@nicolo-ribaudo
Copy link
Member

Q: Is it unique [any type] or only unique symbol?

@existentialism existentialism added the PR: New Feature 🚀 A type of pull request used for our changelog categories label Jan 18, 2018
@ghost
Copy link
Author

ghost commented Jan 18, 2018

We parse unique as a type operator, so any type will parse after it. But only unique symbol will type-check without error. If you write unique number there will be a grammar diagnostic.

@azz
Copy link
Member

azz commented Jan 18, 2018

Is it worth setting prefix: true on the TSTypeOperator node? If not I can remove it from the tsep PR.

@ghost
Copy link
Author

ghost commented Jan 19, 2018

There's no such property in the TypeScript implementation, so I don't think it's worth adding yet. ArrayTypeNode is a separate node kind, so there aren't any postfix type operators.

@hzoo
Copy link
Member

hzoo commented Jan 22, 2018

I guess we technically would want a test to see that it's stripped out but AST structure is the same so it's covered.

@hzoo hzoo merged commit dccfed3 into babel:master Jan 22, 2018
@ghost ghost deleted the ts_unique_symbol branch January 22, 2018 21:23
aminmarashi pushed a commit to aminmarashi/babel that referenced this pull request Mar 17, 2018
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 2, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 2, 2018
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: New Feature 🚀 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants