-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Union and intersection types with leading operator #12386
Union and intersection types with leading operator #12386
Conversation
Hi @mariusschulz, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
@@ -2615,6 +2615,7 @@ namespace ts { | |||
} | |||
|
|||
function parseUnionOrIntersectionType(kind: SyntaxKind, parseConstituentType: () => TypeNode, operator: SyntaxKind): TypeNode { | |||
parseOptional(operator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to also add SyntaxKind.BarToken
and SyntaxKind.AmpersandToken
to the isStartOfType
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Should I add another test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a good idea. For example, looking at where isStartOfType
is called, we wouldn't properly handle a tuple type [| 0 | 1, | "foo" | "bar"]
without this change, so maybe add a test for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I've updated both test files.
@mariusschulz Thanks! |
Fixes #12071
This pull request allows an ignored leading
|
or&
in a type position to give developers more formatting freedom, e.g. like this: