Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2986,7 +2986,7 @@ namespace ts {
return parseFunctionOrConstructorType(SyntaxKind.ConstructorType);
}
const type = parseUnionTypeOrHigher();
if (!noConditionalTypes && parseOptional(SyntaxKind.ExtendsKeyword)) {
if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(SyntaxKind.ExtendsKeyword)) {
const node = <ConditionalTypeNode>createNode(SyntaxKind.ConditionalType, type.pos);
node.checkType = type;
// The type following 'extends' is not permitted to be another conditional type
Expand Down
18 changes: 18 additions & 0 deletions tests/baselines/reference/conditionalTypesASI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//// [conditionalTypesASI.ts]
// Repro from #21637

interface JSONSchema4 {
a?: number
extends?: string | string[]
}


//// [conditionalTypesASI.js]
// Repro from #21637


//// [conditionalTypesASI.d.ts]
interface JSONSchema4 {
a?: number;
extends?: string | string[];
}
13 changes: 13 additions & 0 deletions tests/baselines/reference/conditionalTypesASI.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== tests/cases/compiler/conditionalTypesASI.ts ===
// Repro from #21637

interface JSONSchema4 {
>JSONSchema4 : Symbol(JSONSchema4, Decl(conditionalTypesASI.ts, 0, 0))

a?: number
>a : Symbol(JSONSchema4.a, Decl(conditionalTypesASI.ts, 2, 23))

extends?: string | string[]
>extends : Symbol(JSONSchema4.extends, Decl(conditionalTypesASI.ts, 3, 12))
}

13 changes: 13 additions & 0 deletions tests/baselines/reference/conditionalTypesASI.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== tests/cases/compiler/conditionalTypesASI.ts ===
// Repro from #21637

interface JSONSchema4 {
>JSONSchema4 : JSONSchema4

a?: number
>a : number

extends?: string | string[]
>extends : string | string[]
}

8 changes: 8 additions & 0 deletions tests/cases/compiler/conditionalTypesASI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @declaration: true

// Repro from #21637

interface JSONSchema4 {
a?: number
extends?: string | string[]
}