fix(ts): include leading operator in TSUnionType and TSIntersectionType locations (#12757)

This commit is contained in:
Federico Ciardi
2021-02-04 19:24:35 +01:00
committed by GitHub
parent 0fdec6b7e7
commit d1cf66e8c1
3 changed files with 100 additions and 5 deletions

View File

@@ -935,6 +935,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
parseConstituentType: () => N.TsType,
operator: TokenType,
): N.TsType {
const node: N.TsUnionType | N.TsIntersectionType = this.startNode();
this.eat(operator);
let type = parseConstituentType();
if (this.match(operator)) {
@@ -942,9 +943,6 @@ export default (superClass: Class<Parser>): Class<Parser> =>
while (this.eat(operator)) {
types.push(parseConstituentType());
}
const node: N.TsUnionType | N.TsIntersectionType = this.startNodeAtNode(
type,
);
node.types = types;
type = this.finishNode(node, kind);
}