Merge pull request #21649 from Microsoft/conditionalTypesASI

Conditional types ASI
This commit is contained in:
Anders Hejlsberg
2018-02-05 16:21:34 -08:00
committed by GitHub
5 changed files with 53 additions and 1 deletions

View File

@@ -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

View File

@@ -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[];
}

View File

@@ -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))
}

View File

@@ -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[]
}

View File

@@ -0,0 +1,8 @@
// @declaration: true
// Repro from #21637
interface JSONSchema4 {
a?: number
extends?: string | string[]
}