@@ -728,9 +728,9 @@ namespace ts {
728
728
const keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
729
729
const numberOrBigIntType = getUnionType([numberType, bigintType]);
730
730
731
- const identityMapper: TypeMapper = { kind: TypeMapKind.Function, func: t => t } ;
732
- const restrictiveMapper: TypeMapper = { kind: TypeMapKind.Function, func: t => t.flags & TypeFlags.TypeParameter ? getRestrictiveTypeParameter(<TypeParameter>t) : t } ;
733
- const permissiveMapper: TypeMapper = { kind: TypeMapKind.Function, func: t => t.flags & TypeFlags.TypeParameter ? wildcardType : t } ;
731
+ const identityMapper: TypeMapper = makeFunctionTypeMapper( t => t) ;
732
+ const restrictiveMapper: TypeMapper = makeFunctionTypeMapper( t => t.flags & TypeFlags.TypeParameter ? getRestrictiveTypeParameter(<TypeParameter>t) : t) ;
733
+ const permissiveMapper: TypeMapper = makeFunctionTypeMapper( t => t.flags & TypeFlags.TypeParameter ? wildcardType : t) ;
734
734
735
735
const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
736
736
const emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
@@ -13544,7 +13544,7 @@ namespace ts {
13544
13544
function createTypeMapper(sources: readonly TypeParameter[], targets: readonly Type[] | undefined): TypeMapper {
13545
13545
return sources.length === 1 ?
13546
13546
makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) :
13547
- { kind: TypeMapKind.Multiple, sources, targets } ;
13547
+ makeMultipleTypeMapper( sources, targets) ;
13548
13548
}
13549
13549
13550
13550
function getMappedType(type: Type, map: TypeMapper): Type {
@@ -13569,6 +13569,10 @@ namespace ts {
13569
13569
return { kind: TypeMapKind.Single, source, target };
13570
13570
}
13571
13571
13572
+ function makeMultipleTypeMapper(sources: readonly TypeParameter[], targets: readonly Type[] | undefined): TypeMapper {
13573
+ return { kind: TypeMapKind.Multiple, sources, targets };
13574
+ }
13575
+
13572
13576
function makeFunctionTypeMapper(func: (t: Type) => Type): TypeMapper {
13573
13577
return { kind: TypeMapKind.Function, func };
13574
13578
}
@@ -13582,7 +13586,7 @@ namespace ts {
13582
13586
* This is used during inference when instantiating type parameter defaults.
13583
13587
*/
13584
13588
function createBackreferenceMapper(context: InferenceContext, index: number): TypeMapper {
13585
- return { kind: TypeMapKind.Function, func: t => findIndex(context.inferences, info => info.typeParameter === t) >= index ? unknownType : t } ;
13589
+ return makeFunctionTypeMapper( t => findIndex(context.inferences, info => info.typeParameter === t) >= index ? unknownType : t) ;
13586
13590
}
13587
13591
13588
13592
function getTypeMapperSources(mapper: TypeMapper) {
0 commit comments