diff --git a/src/parser.ts b/src/parser.ts index 58050e837e..7c69843973 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -631,7 +631,7 @@ export class Parser extends DiagnosticEmitter { } // ... | type while (tn.skip(Token.Bar)) { - let nextType = this.parseType(tn, false, true); + let nextType = this.parseType(tn, true, false); if (!nextType) return null; let typeIsNull = type.kind == NodeKind.NamedType && (type).isNull; let nextTypeIsNull = nextType.kind == NodeKind.NamedType && (nextType).isNull; diff --git a/tests/parser/union.ts b/tests/parser/union.ts new file mode 100644 index 0000000000..3d947fe09a --- /dev/null +++ b/tests/parser/union.ts @@ -0,0 +1,9 @@ +export function foo(a: aaa | bbb | ccc): i32 { + return 1; +} + +export function bar(a: i32 | u32 | f32): i32 { + return 1; +} + +export let a: i32 | u32 | f32 | null = 1; diff --git a/tests/parser/union.ts.fixture.ts b/tests/parser/union.ts.fixture.ts new file mode 100644 index 0000000000..b2fb8611bf --- /dev/null +++ b/tests/parser/union.ts.fixture.ts @@ -0,0 +1,4 @@ +export let a = 1; +// ERROR 100: "Not implemented: union types" in union.ts(1,36+3) +// ERROR 100: "Not implemented: union types" in union.ts(5,36+3) +// ERROR 100: "Not implemented: union types" in union.ts(9,27+10)