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(ts): include leading operator in TSUnionType and TSIntersectionType locations #12757

Merged
merged 3 commits into from Feb 4, 2021

Conversation

fedeci
Copy link
Member

@fedeci fedeci commented Feb 4, 2021

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

We save the location of the leading operator token and use that to start TSUnionType and TSIntersectionType nodes.

@existentialism existentialism added pkg: parser PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Feb 4, 2021
@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 4, 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 0ad3952:

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

@babel-bot
Copy link
Collaborator

babel-bot commented Feb 4, 2021

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

@armano2
Copy link
Contributor

armano2 commented Feb 4, 2021

there is one more case that should be taken into account:

type M = | number
type M = & number

typescript in this case generates union type to and babel does not, unless this should be done in separate PR

@JLHwung
Copy link
Contributor

JLHwung commented Feb 4, 2021

typescript-eslint also generates TSUnionType: https://astexplorer.net/#/gist/26a69b81ec7db30e30ec05b387673f6a/f69200243fd8bdff13b85238e53688490c0adae0

I think we should align to TypeScript and typescript-eslint. @fedeci Can you work on a fix on that?

@fedeci
Copy link
Member Author

fedeci commented Feb 4, 2021

@JLHwung yes, should I open a new PR for that?

@existentialism
Copy link
Member

@fedeci yeah let's do a new pr

@nicolo-ribaudo nicolo-ribaudo merged commit d1cf66e into babel:main Feb 4, 2021
@nicolo-ribaudo
Copy link
Member

Thanks!

@fedeci fedeci deleted the fix-typealias-leading-operator branch February 4, 2021 19:08
@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 May 7, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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.

@babel/parser(ts): TSUnionType is not including leading pipe into range
6 participants