@@ -404,10 +404,10 @@ namespace ts {
404404 const wildcardType = createIntrinsicType(TypeFlags.Any, "any");
405405 const errorType = createIntrinsicType(TypeFlags.Any, "error");
406406 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);
411411 const stringType = createIntrinsicType(TypeFlags.String, "string");
412412 const numberType = createIntrinsicType(TypeFlags.Number, "number");
413413 const bigintType = createIntrinsicType(TypeFlags.BigInt, "bigint");
@@ -433,6 +433,7 @@ namespace ts {
433433 const voidType = createIntrinsicType(TypeFlags.Void, "void");
434434 const neverType = createIntrinsicType(TypeFlags.Never, "never");
435435 const silentNeverType = createIntrinsicType(TypeFlags.Never, "never");
436+ const nonInferrableType = createIntrinsicType(TypeFlags.Never, "never", ObjectFlags.NonInferrableType);
436437 const implicitNeverType = createIntrinsicType(TypeFlags.Never, "never");
437438 const nonPrimitiveType = createIntrinsicType(TypeFlags.NonPrimitive, "object");
438439 const stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]);
@@ -453,7 +454,7 @@ namespace ts {
453454 const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
454455 // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
455456 // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes.
456- anyFunctionType.objectFlags |= ObjectFlags.ContainsAnyFunctionType ;
457+ anyFunctionType.objectFlags |= ObjectFlags.NonInferrableType ;
457458
458459 const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
459460 const circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
@@ -2797,14 +2798,9 @@ namespace ts {
27972798 return result;
27982799 }
27992800
2800- function createIntrinsicType(kind: TypeFlags, intrinsicName: string): IntrinsicType {
2801+ function createIntrinsicType(kind: TypeFlags, intrinsicName: string, objectFlags: ObjectFlags = 0 ): IntrinsicType {
28012802 const type = <IntrinsicType>createType(kind);
28022803 type.intrinsicName = intrinsicName;
2803- return type;
2804- }
2805-
2806- function createNullableType(kind: TypeFlags, intrinsicName: string, objectFlags: ObjectFlags): NullableType {
2807- const type = createIntrinsicType(kind, intrinsicName);
28082804 type.objectFlags = objectFlags;
28092805 return type;
28102806 }
@@ -14506,16 +14502,10 @@ namespace ts {
1450614502 }
1450714503
1450814504 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- }
1451314505 // If any property contains context sensitive functions that have been skipped, the source type
1451414506 // 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;
1451914509 }
1452014510 // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been
1452114511 // applied to the element type(s).
@@ -14670,7 +14660,7 @@ namespace ts {
1467014660 // not contain anyFunctionType when we come back to this argument for its second round
1467114661 // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
1467214662 // 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))) {
1467414664 return;
1467514665 }
1467614666 const inference = getInferenceInfoForType(target);
@@ -14991,7 +14981,7 @@ namespace ts {
1499114981 const sourceLen = sourceSignatures.length;
1499214982 const targetLen = targetSignatures.length;
1499314983 const len = sourceLen < targetLen ? sourceLen : targetLen;
14994- const skipParameters = !!(getObjectFlags(source) & ObjectFlags.ContainsAnyFunctionType );
14984+ const skipParameters = !!(getObjectFlags(source) & ObjectFlags.NonInferrableType );
1499514985 for (let i = 0; i < len; i++) {
1499614986 inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getBaseSignature(targetSignatures[targetLen - len + i]), skipParameters);
1499714987 }
@@ -21120,7 +21110,7 @@ namespace ts {
2112021110 // returns a function type, we choose to defer processing. This narrowly permits function composition
2112121111 // operators to flow inferences through return types, but otherwise processes calls right away. We
2112221112 // 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
2112421114 // from which we never make inferences).
2112521115 if (checkMode & CheckMode.SkipGenericFunctions && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
2112621116 skippedGenericFunction(node, checkMode);
@@ -21603,8 +21593,8 @@ namespace ts {
2160321593 const signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode);
2160421594 if (signature === resolvingSignature) {
2160521595 // 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 ;
2160821598 }
2160921599
2161021600 if (node.expression.kind === SyntaxKind.SuperKeyword) {
@@ -22411,7 +22401,7 @@ namespace ts {
2241122401 const returnType = getReturnTypeFromBody(node, checkMode);
2241222402 const returnOnlySignature = createSignature(undefined, undefined, undefined, emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
2241322403 const returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], emptyArray, undefined, undefined);
22414- returnOnlyType.objectFlags |= ObjectFlags.ContainsAnyFunctionType ;
22404+ returnOnlyType.objectFlags |= ObjectFlags.NonInferrableType ;
2241522405 return links.contextFreeType = returnOnlyType;
2241622406 }
2241722407 return anyFunctionType;
0 commit comments