Skip to content

Conversation

mariusschulz
Copy link
Contributor

Fixes #12071

This pull request allows an ignored leading | or & in a type position to give developers more formatting freedom, e.g. like this:

type ReduxAction =
  | { type: "INCREMENT" }
  | { type: "DECREMENT" }
  | { type: "SET_VALUE", value: number };

@msftclas
Copy link

Hi @mariusschulz, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!
We will now validate the agreement and then real humans will evaluate your PR.

TTYL, MSBOT;

}

function parseUnionOrIntersectionType(kind: SyntaxKind, parseConstituentType: () => TypeNode, operator: SyntaxKind): TypeNode {
parseOptional(operator);
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

@ahejlsberg ahejlsberg merged commit c89b1eb into microsoft:master Nov 28, 2016
@ahejlsberg
Copy link
Member

@mariusschulz Thanks!

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.

3 participants