@@ -404,10 +404,10 @@ namespace ts {
404
404
const wildcardType = createIntrinsicType(TypeFlags.Any, "any");
405
405
const errorType = createIntrinsicType(TypeFlags.Any, "error");
406
406
const unknownType = createIntrinsicType(TypeFlags.Unknown, "unknown");
407
- const undefinedType = createNullableType (TypeFlags.Undefined, "undefined", 0 );
408
- const undefinedWideningType = strictNullChecks ? undefinedType : createNullableType (TypeFlags.Undefined, "undefined", ObjectFlags.ContainsWideningType);
409
- const nullType = createNullableType (TypeFlags.Null, "null", 0 );
410
- const nullWideningType = strictNullChecks ? nullType : createNullableType (TypeFlags.Null, "null", ObjectFlags.ContainsWideningType);
407
+ const undefinedType = createIntrinsicType (TypeFlags.Undefined, "undefined");
408
+ const undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType (TypeFlags.Undefined, "undefined", ObjectFlags.ContainsWideningType);
409
+ const nullType = createIntrinsicType (TypeFlags.Null, "null");
410
+ const nullWideningType = strictNullChecks ? nullType : createIntrinsicType (TypeFlags.Null, "null", ObjectFlags.ContainsWideningType);
411
411
const stringType = createIntrinsicType(TypeFlags.String, "string");
412
412
const numberType = createIntrinsicType(TypeFlags.Number, "number");
413
413
const bigintType = createIntrinsicType(TypeFlags.BigInt, "bigint");
@@ -433,6 +433,7 @@ namespace ts {
433
433
const voidType = createIntrinsicType(TypeFlags.Void, "void");
434
434
const neverType = createIntrinsicType(TypeFlags.Never, "never");
435
435
const silentNeverType = createIntrinsicType(TypeFlags.Never, "never");
436
+ const nonInferrableType = createIntrinsicType(TypeFlags.Never, "never", ObjectFlags.NonInferrableType);
436
437
const implicitNeverType = createIntrinsicType(TypeFlags.Never, "never");
437
438
const nonPrimitiveType = createIntrinsicType(TypeFlags.NonPrimitive, "object");
438
439
const stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]);
@@ -453,7 +454,7 @@ namespace ts {
453
454
const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
454
455
// The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
455
456
// in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes.
456
- anyFunctionType.objectFlags |= ObjectFlags.ContainsAnyFunctionType ;
457
+ anyFunctionType.objectFlags |= ObjectFlags.NonInferrableType ;
457
458
458
459
const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
459
460
const circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
@@ -2797,14 +2798,9 @@ namespace ts {
2797
2798
return result;
2798
2799
}
2799
2800
2800
- function createIntrinsicType(kind: TypeFlags, intrinsicName: string): IntrinsicType {
2801
+ function createIntrinsicType(kind: TypeFlags, intrinsicName: string, objectFlags: ObjectFlags = 0 ): IntrinsicType {
2801
2802
const type = <IntrinsicType>createType(kind);
2802
2803
type.intrinsicName = intrinsicName;
2803
- return type;
2804
- }
2805
-
2806
- function createNullableType(kind: TypeFlags, intrinsicName: string, objectFlags: ObjectFlags): NullableType {
2807
- const type = createIntrinsicType(kind, intrinsicName);
2808
2804
type.objectFlags = objectFlags;
2809
2805
return type;
2810
2806
}
@@ -14506,16 +14502,10 @@ namespace ts {
14506
14502
}
14507
14503
14508
14504
function createReverseMappedType(source: Type, target: MappedType, constraint: IndexType) {
14509
- const properties = getPropertiesOfType(source);
14510
- if (properties.length === 0 && !getIndexInfoOfType(source, IndexKind.String)) {
14511
- return undefined;
14512
- }
14513
14505
// If any property contains context sensitive functions that have been skipped, the source type
14514
14506
// is incomplete and we can't infer a meaningful input type.
14515
- for (const prop of properties) {
14516
- if (getObjectFlags(getTypeOfSymbol(prop)) & ObjectFlags.ContainsAnyFunctionType) {
14517
- return undefined;
14518
- }
14507
+ if (getObjectFlags(source) & ObjectFlags.NonInferrableType || getPropertiesOfType(source).length === 0 && !getIndexInfoOfType(source, IndexKind.String)) {
14508
+ return undefined;
14519
14509
}
14520
14510
// For arrays and tuples we infer new arrays and tuples where the reverse mapping has been
14521
14511
// applied to the element type(s).
@@ -14670,7 +14660,7 @@ namespace ts {
14670
14660
// not contain anyFunctionType when we come back to this argument for its second round
14671
14661
// of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
14672
14662
// when constructing types from type parameters that had no inference candidates).
14673
- if (getObjectFlags(source) & ObjectFlags.ContainsAnyFunctionType || source === silentNeverType || (priority & InferencePriority.ReturnType && (source === autoType || source === autoArrayType))) {
14663
+ if (getObjectFlags(source) & ObjectFlags.NonInferrableType || source === silentNeverType || (priority & InferencePriority.ReturnType && (source === autoType || source === autoArrayType))) {
14674
14664
return;
14675
14665
}
14676
14666
const inference = getInferenceInfoForType(target);
@@ -14991,7 +14981,7 @@ namespace ts {
14991
14981
const sourceLen = sourceSignatures.length;
14992
14982
const targetLen = targetSignatures.length;
14993
14983
const len = sourceLen < targetLen ? sourceLen : targetLen;
14994
- const skipParameters = !!(getObjectFlags(source) & ObjectFlags.ContainsAnyFunctionType );
14984
+ const skipParameters = !!(getObjectFlags(source) & ObjectFlags.NonInferrableType );
14995
14985
for (let i = 0; i < len; i++) {
14996
14986
inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getBaseSignature(targetSignatures[targetLen - len + i]), skipParameters);
14997
14987
}
@@ -21120,7 +21110,7 @@ namespace ts {
21120
21110
// returns a function type, we choose to defer processing. This narrowly permits function composition
21121
21111
// operators to flow inferences through return types, but otherwise processes calls right away. We
21122
21112
// use the resolvingSignature singleton to indicate that we deferred processing. This result will be
21123
- // propagated out and eventually turned into silentNeverType (a type that is assignable to anything and
21113
+ // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and
21124
21114
// from which we never make inferences).
21125
21115
if (checkMode & CheckMode.SkipGenericFunctions && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
21126
21116
skippedGenericFunction(node, checkMode);
@@ -21603,8 +21593,8 @@ namespace ts {
21603
21593
const signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode);
21604
21594
if (signature === resolvingSignature) {
21605
21595
// CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that
21606
- // returns a function type. We defer checking and return anyFunctionType .
21607
- return silentNeverType ;
21596
+ // returns a function type. We defer checking and return nonInferrableType .
21597
+ return nonInferrableType ;
21608
21598
}
21609
21599
21610
21600
if (node.expression.kind === SyntaxKind.SuperKeyword) {
@@ -22411,7 +22401,7 @@ namespace ts {
22411
22401
const returnType = getReturnTypeFromBody(node, checkMode);
22412
22402
const returnOnlySignature = createSignature(undefined, undefined, undefined, emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
22413
22403
const returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], emptyArray, undefined, undefined);
22414
- returnOnlyType.objectFlags |= ObjectFlags.ContainsAnyFunctionType ;
22404
+ returnOnlyType.objectFlags |= ObjectFlags.NonInferrableType ;
22415
22405
return links.contextFreeType = returnOnlyType;
22416
22406
}
22417
22407
return anyFunctionType;
0 commit comments