mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-12 20:01:02 -05:00
Merge pull request #21649 from Microsoft/conditionalTypesASI
Conditional types ASI
This commit is contained in:
@@ -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
|
||||
|
||||
18
tests/baselines/reference/conditionalTypesASI.js
Normal file
18
tests/baselines/reference/conditionalTypesASI.js
Normal 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[];
|
||||
}
|
||||
13
tests/baselines/reference/conditionalTypesASI.symbols
Normal file
13
tests/baselines/reference/conditionalTypesASI.symbols
Normal 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))
|
||||
}
|
||||
|
||||
13
tests/baselines/reference/conditionalTypesASI.types
Normal file
13
tests/baselines/reference/conditionalTypesASI.types
Normal 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[]
|
||||
}
|
||||
|
||||
8
tests/cases/compiler/conditionalTypesASI.ts
Normal file
8
tests/cases/compiler/conditionalTypesASI.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// @declaration: true
|
||||
|
||||
// Repro from #21637
|
||||
|
||||
interface JSONSchema4 {
|
||||
a?: number
|
||||
extends?: string | string[]
|
||||
}
|
||||
Reference in New Issue
Block a user