@@ -265,6 +265,7 @@ namespace ts {
265265 TupleType ,
266266 UnionType ,
267267 IntersectionType ,
268+ ConditionalType ,
268269 ParenthesizedType ,
269270 ThisType ,
270271 TypeOperator ,
@@ -1116,6 +1117,14 @@ namespace ts {
11161117 types : NodeArray < TypeNode > ;
11171118 }
11181119
1120+ export interface ConditionalTypeNode extends TypeNode {
1121+ kind : SyntaxKind . ConditionalType ;
1122+ checkType : TypeNode ;
1123+ extendsType : TypeNode ;
1124+ trueType : TypeNode ;
1125+ falseType : TypeNode ;
1126+ }
1127+
11191128 export interface ParenthesizedTypeNode extends TypeNode {
11201129 kind : SyntaxKind . ParenthesizedType ;
11211130 type : TypeNode ;
@@ -3484,18 +3493,19 @@ namespace ts {
34843493 Intersection = 1 << 18 , // Intersection (T & U)
34853494 Index = 1 << 19 , // keyof T
34863495 IndexedAccess = 1 << 20 , // T[K]
3496+ Conditional = 1 << 21 , // T extends U ? X : Y
3497+ Substitution = 1 << 22 , // Type parameter substitution
34873498 /* @internal */
3488- FreshLiteral = 1 << 21 , // Fresh literal or unique type
3499+ FreshLiteral = 1 << 23 , // Fresh literal or unique type
34893500 /* @internal */
3490- ContainsWideningType = 1 << 22 , // Type is or contains undefined or null widening type
3501+ ContainsWideningType = 1 << 24 , // Type is or contains undefined or null widening type
34913502 /* @internal */
3492- ContainsObjectLiteral = 1 << 23 , // Type is or contains object literal type
3503+ ContainsObjectLiteral = 1 << 25 , // Type is or contains object literal type
34933504 /* @internal */
3494- ContainsAnyFunctionType = 1 << 24 , // Type is or contains the anyFunctionType
3495- NonPrimitive = 1 << 25 , // intrinsic object type
3505+ ContainsAnyFunctionType = 1 << 26 , // Type is or contains the anyFunctionType
3506+ NonPrimitive = 1 << 27 , // intrinsic object type
34963507 /* @internal */
3497- JsxAttributes = 1 << 26 , // Jsx attributes type
3498- MarkerType = 1 << 27 , // Marker type used for variance probing
3508+ GenericMappedType = 1 << 29 , // Flag used by maybeTypeOfKind
34993509
35003510 /* @internal */
35013511 Nullable = Undefined | Null ,
@@ -3518,17 +3528,21 @@ namespace ts {
35183528 ESSymbolLike = ESSymbol | UniqueESSymbol ,
35193529 UnionOrIntersection = Union | Intersection ,
35203530 StructuredType = Object | Union | Intersection ,
3521- StructuredOrTypeVariable = StructuredType | TypeParameter | Index | IndexedAccess ,
35223531 TypeVariable = TypeParameter | IndexedAccess ,
3532+ InstantiableNonPrimitive = TypeVariable | Conditional | Substitution ,
3533+ InstantiablePrimitive = Index ,
3534+ Instantiable = InstantiableNonPrimitive | InstantiablePrimitive ,
3535+ StructuredOrInstantiable = StructuredType | Instantiable ,
35233536
35243537 // 'Narrowable' types are types where narrowing actually narrows.
35253538 // This *should* be every type other than null, undefined, void, and never
3526- Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive ,
3539+ Narrowable = Any | StructuredOrInstantiable | StringLike | NumberLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive ,
35273540 NotUnionOrUnit = Any | ESSymbol | Object | NonPrimitive ,
35283541 /* @internal */
35293542 RequiresWidening = ContainsWideningType | ContainsObjectLiteral ,
35303543 /* @internal */
35313544 PropagatingFlags = ContainsWideningType | ContainsObjectLiteral | ContainsAnyFunctionType ,
3545+ /* @internal */
35323546 }
35333547
35343548 export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression ;
@@ -3587,7 +3601,9 @@ namespace ts {
35873601 EvolvingArray = 1 << 8 , // Evolving array type
35883602 ObjectLiteralPatternWithComputedProperties = 1 << 9 , // Object literal pattern with computed properties
35893603 ContainsSpread = 1 << 10 , // Object literal contains spread operation
3590- ReverseMapped = 1 << 11 , // Object contains a property from a reverse-mapped type
3604+ ReverseMapped = 1 << 11 , // Object contains a property from a reverse-mapped type
3605+ JsxAttributes = 1 << 12 , // Jsx attributes type
3606+ MarkerType = 1 << 13 , // Marker type used for variance probing
35913607 ClassOrInterface = Class | Interface
35923608 }
35933609
@@ -3741,15 +3757,15 @@ namespace ts {
37413757 syntheticType ?: Type ;
37423758 }
37433759
3744- export interface TypeVariable extends Type {
3760+ export interface InstantiableType extends Type {
37453761 /* @internal */
37463762 resolvedBaseConstraint ?: Type ;
37473763 /* @internal */
37483764 resolvedIndexType ?: IndexType ;
37493765 }
37503766
37513767 // Type parameters (TypeFlags.TypeParameter)
3752- export interface TypeParameter extends TypeVariable {
3768+ export interface TypeParameter extends InstantiableType {
37533769 /** Retrieve using getConstraintFromTypeParameter */
37543770 /* @internal */
37553771 constraint ?: Type ; // Constraint
@@ -3767,15 +3783,38 @@ namespace ts {
37673783
37683784 // Indexed access types (TypeFlags.IndexedAccess)
37693785 // Possible forms are T[xxx], xxx[T], or xxx[keyof T], where T is a type variable
3770- export interface IndexedAccessType extends TypeVariable {
3786+ export interface IndexedAccessType extends InstantiableType {
37713787 objectType : Type ;
37723788 indexType : Type ;
37733789 constraint ?: Type ;
37743790 }
37753791
37763792 // keyof T types (TypeFlags.Index)
3777- export interface IndexType extends Type {
3778- type : TypeVariable | UnionOrIntersectionType ;
3793+ export interface IndexType extends InstantiableType {
3794+ type : InstantiableType | UnionOrIntersectionType ;
3795+ }
3796+
3797+ // T extends U ? X : Y (TypeFlags.Conditional)
3798+ export interface ConditionalType extends InstantiableType {
3799+ checkType : Type ;
3800+ extendsType : Type ;
3801+ trueType : Type ;
3802+ falseType : Type ;
3803+ /* @internal */
3804+ target ?: ConditionalType ;
3805+ /* @internal */
3806+ mapper ?: TypeMapper ;
3807+ }
3808+
3809+ // Type parameter substitution (TypeFlags.Substitution)
3810+ // Substitution types are created for type parameter references that occur in the true branch
3811+ // of a conditional type. For example, in 'T extends string ? Foo<T> : Bar<T>', the reference to
3812+ // T in Foo<T> is resolved as a substitution type that substitutes 'string & T' for T. Thus, if
3813+ // Foo has a 'string' constraint on its type parameter, T will satisfy it. Substitution types
3814+ // disappear upon instantiation (just like type parameters).
3815+ export interface SubstitutionType extends InstantiableType {
3816+ typeParameter : TypeParameter ; // Target type parameter
3817+ substitute : Type ; // Type to substitute for type parameter
37793818 }
37803819
37813820 export const enum SignatureKind {
0 commit comments