@@ -403,10 +403,10 @@ namespace ts {
403403 const wildcardType = createIntrinsicType(TypeFlags.Any, "any");
404404 const errorType = createIntrinsicType(TypeFlags.Any, "error");
405405 const unknownType = createIntrinsicType(TypeFlags.Unknown, "unknown");
406- const undefinedType = createNullableType (TypeFlags.Undefined, "undefined", 0 );
407- const undefinedWideningType = strictNullChecks ? undefinedType : createNullableType (TypeFlags.Undefined, "undefined", ObjectFlags.ContainsWideningType);
408- const nullType = createNullableType (TypeFlags.Null, "null", 0 );
409- const nullWideningType = strictNullChecks ? nullType : createNullableType (TypeFlags.Null, "null", ObjectFlags.ContainsWideningType);
406+ const undefinedType = createIntrinsicType (TypeFlags.Undefined, "undefined");
407+ const undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType (TypeFlags.Undefined, "undefined", ObjectFlags.ContainsWideningType);
408+ const nullType = createIntrinsicType (TypeFlags.Null, "null");
409+ const nullWideningType = strictNullChecks ? nullType : createIntrinsicType (TypeFlags.Null, "null", ObjectFlags.ContainsWideningType);
410410 const stringType = createIntrinsicType(TypeFlags.String, "string");
411411 const numberType = createIntrinsicType(TypeFlags.Number, "number");
412412 const bigintType = createIntrinsicType(TypeFlags.BigInt, "bigint");
@@ -432,6 +432,7 @@ namespace ts {
432432 const voidType = createIntrinsicType(TypeFlags.Void, "void");
433433 const neverType = createIntrinsicType(TypeFlags.Never, "never");
434434 const silentNeverType = createIntrinsicType(TypeFlags.Never, "never");
435+ const nonInferrableType = createIntrinsicType(TypeFlags.Never, "never", ObjectFlags.NonInferrableType);
435436 const implicitNeverType = createIntrinsicType(TypeFlags.Never, "never");
436437 const nonPrimitiveType = createIntrinsicType(TypeFlags.NonPrimitive, "object");
437438 const stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]);
@@ -452,7 +453,7 @@ namespace ts {
452453 const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
453454 // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
454455 // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes.
455- anyFunctionType.objectFlags |= ObjectFlags.ContainsAnyFunctionType ;
456+ anyFunctionType.objectFlags |= ObjectFlags.NonInferrableType ;
456457
457458 const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
458459 const circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
@@ -2753,14 +2754,9 @@ namespace ts {
27532754 return result;
27542755 }
27552756
2756- function createIntrinsicType(kind: TypeFlags, intrinsicName: string): IntrinsicType {
2757+ function createIntrinsicType(kind: TypeFlags, intrinsicName: string, objectFlags: ObjectFlags = 0 ): IntrinsicType {
27572758 const type = <IntrinsicType>createType(kind);
27582759 type.intrinsicName = intrinsicName;
2759- return type;
2760- }
2761-
2762- function createNullableType(kind: TypeFlags, intrinsicName: string, objectFlags: ObjectFlags): NullableType {
2763- const type = createIntrinsicType(kind, intrinsicName);
27642760 type.objectFlags = objectFlags;
27652761 return type;
27662762 }
@@ -14455,16 +14451,10 @@ namespace ts {
1445514451 }
1445614452
1445714453 function createReverseMappedType(source: Type, target: MappedType, constraint: IndexType) {
14458- const properties = getPropertiesOfType(source);
14459- if (properties.length === 0 && !getIndexInfoOfType(source, IndexKind.String)) {
14460- return undefined;
14461- }
1446214454 // If any property contains context sensitive functions that have been skipped, the source type
1446314455 // is incomplete and we can't infer a meaningful input type.
14464- for (const prop of properties) {
14465- if (getObjectFlags(getTypeOfSymbol(prop)) & ObjectFlags.ContainsAnyFunctionType) {
14466- return undefined;
14467- }
14456+ if (getObjectFlags(source) & ObjectFlags.NonInferrableType || getPropertiesOfType(source).length === 0 && !getIndexInfoOfType(source, IndexKind.String)) {
14457+ return undefined;
1446814458 }
1446914459 // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been
1447014460 // applied to the element type(s).
@@ -14619,7 +14609,7 @@ namespace ts {
1461914609 // not contain anyFunctionType when we come back to this argument for its second round
1462014610 // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
1462114611 // when constructing types from type parameters that had no inference candidates).
14622- if (getObjectFlags(source) & ObjectFlags.ContainsAnyFunctionType || source === silentNeverType || (priority & InferencePriority.ReturnType && (source === autoType || source === autoArrayType))) {
14612+ if (getObjectFlags(source) & ObjectFlags.NonInferrableType || source === silentNeverType || (priority & InferencePriority.ReturnType && (source === autoType || source === autoArrayType))) {
1462314613 return;
1462414614 }
1462514615 const inference = getInferenceInfoForType(target);
@@ -14932,7 +14922,7 @@ namespace ts {
1493214922 const sourceLen = sourceSignatures.length;
1493314923 const targetLen = targetSignatures.length;
1493414924 const len = sourceLen < targetLen ? sourceLen : targetLen;
14935- const skipParameters = !!(getObjectFlags(source) & ObjectFlags.ContainsAnyFunctionType );
14925+ const skipParameters = !!(getObjectFlags(source) & ObjectFlags.NonInferrableType );
1493614926 for (let i = 0; i < len; i++) {
1493714927 inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getBaseSignature(targetSignatures[targetLen - len + i]), skipParameters);
1493814928 }
@@ -21052,7 +21042,7 @@ namespace ts {
2105221042 // returns a function type, we choose to defer processing. This narrowly permits function composition
2105321043 // operators to flow inferences through return types, but otherwise processes calls right away. We
2105421044 // use the resolvingSignature singleton to indicate that we deferred processing. This result will be
21055- // propagated out and eventually turned into silentNeverType (a type that is assignable to anything and
21045+ // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and
2105621046 // from which we never make inferences).
2105721047 if (checkMode & CheckMode.SkipGenericFunctions && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
2105821048 skippedGenericFunction(node, checkMode);
@@ -21535,8 +21525,8 @@ namespace ts {
2153521525 const signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode);
2153621526 if (signature === resolvingSignature) {
2153721527 // CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that
21538- // returns a function type. We defer checking and return anyFunctionType .
21539- return silentNeverType ;
21528+ // returns a function type. We defer checking and return nonInferrableType .
21529+ return nonInferrableType ;
2154021530 }
2154121531
2154221532 if (node.expression.kind === SyntaxKind.SuperKeyword) {
@@ -22343,7 +22333,7 @@ namespace ts {
2234322333 const returnType = getReturnTypeFromBody(node, checkMode);
2234422334 const returnOnlySignature = createSignature(undefined, undefined, undefined, emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
2234522335 const returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], emptyArray, undefined, undefined);
22346- returnOnlyType.objectFlags |= ObjectFlags.ContainsAnyFunctionType ;
22336+ returnOnlyType.objectFlags |= ObjectFlags.NonInferrableType ;
2234722337 return links.contextFreeType = returnOnlyType;
2234822338 }
2234922339 return anyFunctionType;
0 commit comments