Skip to content

Commit 1847c8f

Browse files
authored
fix: report error for mulitple union type (#2872)
1 parent 4bd1c12 commit 1847c8f

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/parser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ export class Parser extends DiagnosticEmitter {
631631
}
632632
// ... | type
633633
while (tn.skip(Token.Bar)) {
634-
let nextType = this.parseType(tn, false, true);
634+
let nextType = this.parseType(tn, true, false);
635635
if (!nextType) return null;
636636
let typeIsNull = type.kind == NodeKind.NamedType && (<NamedTypeNode>type).isNull;
637637
let nextTypeIsNull = nextType.kind == NodeKind.NamedType && (<NamedTypeNode>nextType).isNull;

tests/parser/union.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export function foo(a: aaa | bbb | ccc): i32 {
2+
return 1;
3+
}
4+
5+
export function bar(a: i32 | u32 | f32): i32 {
6+
return 1;
7+
}
8+
9+
export let a: i32 | u32 | f32 | null = 1;

tests/parser/union.ts.fixture.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export let a = 1;
2+
// ERROR 100: "Not implemented: union types" in union.ts(1,36+3)
3+
// ERROR 100: "Not implemented: union types" in union.ts(5,36+3)
4+
// ERROR 100: "Not implemented: union types" in union.ts(9,27+10)

0 commit comments

Comments
 (0)