Skip to content

fix parsing of leading union/intersection operator#31265

Merged
rbuckton merged 2 commits into
microsoft:masterfrom
ajafff:leading-operator
May 8, 2019
Merged

fix parsing of leading union/intersection operator#31265
rbuckton merged 2 commits into
microsoft:masterfrom
ajafff:leading-operator

Conversation

@ajafff
Copy link
Copy Markdown
Contributor

@ajafff ajafff commented May 5, 2019

Fixes: #30995

A leading | or & is now part of the union/intersection type's range.
If there's a leading operator and only one constituent type, we still parse a union/intersection type.

@ajafff
Copy link
Copy Markdown
Contributor Author

ajafff commented May 7, 2019

Closing in favor of #31017

@ajafff
Copy link
Copy Markdown
Contributor Author

ajafff commented May 8, 2019

Reopening as this PR actually fixes the floating token issue if there's no further operator

@ajafff ajafff reopened this May 8, 2019
@ajafff
Copy link
Copy Markdown
Contributor Author

ajafff commented May 8, 2019

@rbuckton I added the test case you requested in #31017 (comment): declaration emit ignores leading comments of the leading operator.

@rbuckton
Copy link
Copy Markdown
Contributor

rbuckton commented May 8, 2019

Looks good, thanks!

@rbuckton rbuckton merged commit 0c9db71 into microsoft:master May 8, 2019
@ajafff ajafff deleted the leading-operator branch May 8, 2019 21:10


//// [unionTypeWithLeadingOperator.d.ts]
export declare type D = /*leading1*/ 1 | /*leading2*/ 2;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why /*trailing1*/ is removed?

@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Leading |/& is not included in the intersection/union node

3 participants