@@ -6243,6 +6243,7 @@ export interface NodeLinks {
6243
6243
decoratorSignature ?: Signature ; // Signature for decorator as if invoked by the runtime.
6244
6244
spreadIndices ?: { first : number | undefined , last : number | undefined } ; // Indices of first and last spread elements in array literal
6245
6245
parameterInitializerContainsUndefined ?: boolean ; // True if this is a parameter declaration whose type annotation contains "undefined".
6246
+ contextualReturnType ?: Type ; // If the node is a return statement's expression, then this is the contextual return type.
6246
6247
fakeScopeForSignatureDeclaration ?: "params" | "typeParams" ; // If present, this is a fake scope injected into an enclosing declaration chain.
6247
6248
assertionExpressionType ?: Type ; // Cached type of the expression of a type assertion
6248
6249
potentialThisCollisions ?: Node [ ] ;
@@ -6510,6 +6511,8 @@ export const enum ObjectFlags {
6510
6511
IsGenericIndexType = 1 << 23 , // Union or intersection contains generic index type
6511
6512
/** @internal */
6512
6513
IsGenericType = IsGenericObjectType | IsGenericIndexType ,
6514
+ /** @internal */
6515
+ IsNarrowingType = 1 << 24 , // Substitution type that comes from type narrowing
6513
6516
6514
6517
// Flags that require TypeFlags.Union
6515
6518
/** @internal */
@@ -6909,12 +6912,16 @@ export interface StringMappingType extends InstantiableType {
6909
6912
}
6910
6913
6911
6914
// Type parameter substitution (TypeFlags.Substitution)
6912
- // Substitution types are created for type parameters or indexed access types that occur in the
6915
+ // - Substitution types are created for type parameters or indexed access types that occur in the
6913
6916
// true branch of a conditional type. For example, in 'T extends string ? Foo<T> : Bar<T>', the
6914
6917
// reference to T in Foo<T> is resolved as a substitution type that substitutes 'string & T' for T.
6915
6918
// Thus, if Foo has a 'string' constraint on its type parameter, T will satisfy it.
6916
- // Substitution type are also created for NoInfer<T> types. Those are represented as substitution
6919
+ // - Substitution types are also created for NoInfer<T> types. Those are represented as substitution
6917
6920
// types where the constraint is type 'unknown' (which is never generated for the case above).
6921
+ // - Substitution types are also created for return type narrowing:
6922
+ // if a type parameter `T` is linked to a parameter `x` and `x`'s narrowed type is `S`,
6923
+ // we represent that with a substitution type with base `T` and constraint `S`.
6924
+ // The resulting substitution type has `ObjectFlags.IsNarrowedType` set.
6918
6925
export interface SubstitutionType extends InstantiableType {
6919
6926
objectFlags : ObjectFlags ;
6920
6927
baseType : Type ; // Target type
0 commit comments