Skip to content

Commit 3b220a8

Browse files
authored
Merge pull request microsoft#21649 from Microsoft/conditionalTypesASI
Conditional types ASI
2 parents 905878c + d4d54d6 commit 3b220a8

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2986,7 +2986,7 @@ namespace ts {
29862986
return parseFunctionOrConstructorType(SyntaxKind.ConstructorType);
29872987
}
29882988
const type = parseUnionTypeOrHigher();
2989-
if (!noConditionalTypes && parseOptional(SyntaxKind.ExtendsKeyword)) {
2989+
if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(SyntaxKind.ExtendsKeyword)) {
29902990
const node = <ConditionalTypeNode>createNode(SyntaxKind.ConditionalType, type.pos);
29912991
node.checkType = type;
29922992
// The type following 'extends' is not permitted to be another conditional type
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [conditionalTypesASI.ts]
2+
// Repro from #21637
3+
4+
interface JSONSchema4 {
5+
a?: number
6+
extends?: string | string[]
7+
}
8+
9+
10+
//// [conditionalTypesASI.js]
11+
// Repro from #21637
12+
13+
14+
//// [conditionalTypesASI.d.ts]
15+
interface JSONSchema4 {
16+
a?: number;
17+
extends?: string | string[];
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/compiler/conditionalTypesASI.ts ===
2+
// Repro from #21637
3+
4+
interface JSONSchema4 {
5+
>JSONSchema4 : Symbol(JSONSchema4, Decl(conditionalTypesASI.ts, 0, 0))
6+
7+
a?: number
8+
>a : Symbol(JSONSchema4.a, Decl(conditionalTypesASI.ts, 2, 23))
9+
10+
extends?: string | string[]
11+
>extends : Symbol(JSONSchema4.extends, Decl(conditionalTypesASI.ts, 3, 12))
12+
}
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/compiler/conditionalTypesASI.ts ===
2+
// Repro from #21637
3+
4+
interface JSONSchema4 {
5+
>JSONSchema4 : JSONSchema4
6+
7+
a?: number
8+
>a : number
9+
10+
extends?: string | string[]
11+
>extends : string | string[]
12+
}
13+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @declaration: true
2+
3+
// Repro from #21637
4+
5+
interface JSONSchema4 {
6+
a?: number
7+
extends?: string | string[]
8+
}

0 commit comments

Comments
 (0)