@@ -7325,7 +7325,7 @@ namespace ts {
73257325 const declaredType = <MappedType>getTypeFromMappedTypeNode(type.declaration);
73267326 const constraint = getConstraintTypeFromMappedType(declaredType);
73277327 const extendedConstraint = constraint && constraint.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(<TypeParameter>constraint) : constraint;
7328- type.modifiersType = extendedConstraint && extendedConstraint.flags & TypeFlags.Index ? instantiateType((<IndexType>extendedConstraint).type, type.mapper || identityMapper) : emptyObjectType ;
7328+ type.modifiersType = extendedConstraint && extendedConstraint.flags & TypeFlags.Index ? instantiateType((<IndexType>extendedConstraint).type, type.mapper || identityMapper) : unknownType ;
73297329 }
73307330 }
73317331 return type.modifiersType;
@@ -7768,7 +7768,7 @@ namespace ts {
77687768 * type itself. Note that the apparent type of a union type is the union type itself.
77697769 */
77707770 function getApparentType(type: Type): Type {
7771- const t = type.flags & TypeFlags.Instantiable ? getBaseConstraintOfType(type) || emptyObjectType : type;
7771+ const t = type.flags & TypeFlags.Instantiable ? getBaseConstraintOfType(type) || (strictNullChecks ? unknownType : emptyObjectType) : type;
77727772 return getObjectFlags(t) & ObjectFlags.Mapped ? getApparentTypeOfMappedType(<MappedType>t) :
77737773 t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(<IntersectionType>t) :
77747774 t.flags & TypeFlags.StringLike ? globalStringType :
@@ -8101,7 +8101,7 @@ namespace ts {
81018101 const baseDefaultType = getDefaultTypeArgumentType(isJavaScriptImplicitAny);
81028102 for (let i = numTypeArguments; i < numTypeParameters; i++) {
81038103 let defaultType = getDefaultFromTypeParameter(typeParameters![i]);
8104- if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) {
8104+ if (isJavaScriptImplicitAny && defaultType && ( isTypeIdenticalTo(defaultType, unknownType) || isTypeIdenticalTo(defaultType, emptyObjectType) )) {
81058105 defaultType = anyType;
81068106 }
81078107 result[i] = defaultType ? instantiateType(defaultType, createTypeMapper(typeParameters!, result)) : baseDefaultType;
@@ -8480,7 +8480,7 @@ namespace ts {
84808480 const typeParameters = signature.typeParameters;
84818481 if (typeParameters) {
84828482 const typeEraser = createTypeEraser(typeParameters);
8483- const baseConstraints = map(typeParameters, tp => instantiateType(getBaseConstraintOfType(tp), typeEraser) || emptyObjectType );
8483+ const baseConstraints = map(typeParameters, tp => instantiateType(getBaseConstraintOfType(tp), typeEraser) || unknownType );
84848484 return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true);
84858485 }
84868486 return signature;
@@ -10794,7 +10794,7 @@ namespace ts {
1079410794 * This is used during inference when instantiating type parameter defaults.
1079510795 */
1079610796 function createBackreferenceMapper(context: InferenceContext, index: number): TypeMapper {
10797- return t => findIndex(context.inferences, info => info.typeParameter === t) >= index ? emptyObjectType : t;
10797+ return t => findIndex(context.inferences, info => info.typeParameter === t) >= index ? unknownType : t;
1079810798 }
1079910799
1080010800 function combineTypeMappers(mapper1: TypeMapper | undefined, mapper2: TypeMapper): TypeMapper;
@@ -11341,7 +11341,7 @@ namespace ts {
1134111341 function isTypeDerivedFrom(source: Type, target: Type): boolean {
1134211342 return source.flags & TypeFlags.Union ? every((<UnionType>source).types, t => isTypeDerivedFrom(t, target)) :
1134311343 target.flags & TypeFlags.Union ? some((<UnionType>target).types, t => isTypeDerivedFrom(source, t)) :
11344- source.flags & TypeFlags.InstantiableNonPrimitive ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType , target) :
11344+ source.flags & TypeFlags.InstantiableNonPrimitive ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType , target) :
1134511345 target === globalObjectType ? !!(source.flags & (TypeFlags.Object | TypeFlags.NonPrimitive)) :
1134611346 target === globalFunctionType ? !!(source.flags & TypeFlags.Object) && isFunctionObjectType(source as ObjectType) :
1134711347 hasBaseType(source, getTargetType(target));
@@ -14539,7 +14539,7 @@ namespace ts {
1453914539 function getTypeFromInference(inference: InferenceInfo) {
1454014540 return inference.candidates ? getUnionType(inference.candidates, UnionReduction.Subtype) :
1454114541 inference.contraCandidates ? getIntersectionType(inference.contraCandidates) :
14542- emptyObjectType ;
14542+ unknownType ;
1454314543 }
1454414544
1454514545 function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0, contravariant = false) {
@@ -15097,7 +15097,7 @@ namespace ts {
1509715097 }
1509815098
1509915099 function getDefaultTypeArgumentType(isInJavaScriptFile: boolean): Type {
15100- return isInJavaScriptFile ? anyType : emptyObjectType ;
15100+ return isInJavaScriptFile ? anyType : unknownType ;
1510115101 }
1510215102
1510315103 function getInferredTypes(context: InferenceContext): Type[] {
@@ -15441,7 +15441,7 @@ namespace ts {
1544115441 return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts;
1544215442 }
1544315443 if (flags & TypeFlags.Instantiable) {
15444- return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType );
15444+ return getTypeFacts(getBaseConstraintOfType(type) || unknownType );
1544515445 }
1544615446 if (flags & TypeFlags.UnionOrIntersection) {
1544715447 return getTypeFactsOfTypes((<UnionOrIntersectionType>type).types);
@@ -16752,7 +16752,7 @@ namespace ts {
1675216752 }
1675316753
1675416754 function typeHasNullableConstraint(type: Type) {
16755- return type.flags & TypeFlags.InstantiableNonPrimitive && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType , TypeFlags.Nullable);
16755+ return type.flags & TypeFlags.InstantiableNonPrimitive && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType , TypeFlags.Nullable);
1675616756 }
1675716757
1675816758 function getConstraintForLocation(type: Type, node: Node): Type;
@@ -18194,7 +18194,7 @@ namespace ts {
1819418194 }
1819518195
1819618196 function getJsxPropsTypeFromCallSignature(sig: Signature, context: JsxOpeningLikeElement) {
18197- let propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType );
18197+ let propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType );
1819818198 propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
1819918199 const intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
1820018200 if (intrinsicAttribs !== errorType) {
@@ -18268,7 +18268,7 @@ namespace ts {
1826818268 const forcedLookupLocation = getJsxElementPropertiesName(ns);
1826918269 let attributesType = forcedLookupLocation === undefined
1827018270 // If there is no type ElementAttributesProperty, return the type of the first parameter of the signature, which should be the props type
18271- ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType )
18271+ ? getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType )
1827218272 : forcedLookupLocation === ""
1827318273 // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead
1827418274 ? getReturnTypeOfSignature(sig)
@@ -18280,7 +18280,7 @@ namespace ts {
1828018280 if (!!forcedLookupLocation && !!length(context.attributes.properties)) {
1828118281 error(context, Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, unescapeLeadingUnderscores(forcedLookupLocation));
1828218282 }
18283- return emptyObjectType ;
18283+ return unknownType ;
1828418284 }
1828518285
1828618286 attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType);
@@ -21986,7 +21986,7 @@ namespace ts {
2198621986 const decl = parameter.valueDeclaration as ParameterDeclaration;
2198721987 if (decl.name.kind !== SyntaxKind.Identifier) {
2198821988 // if inference didn't come up with anything but {}, fall back to the binding pattern if present.
21989- if (links.type === emptyObjectType ) {
21989+ if (links.type === unknownType ) {
2199021990 links.type = getTypeFromBindingPattern(decl.name);
2199121991 }
2199221992 assignBindingElementTypes(decl.name);
@@ -21999,28 +21999,28 @@ namespace ts {
2199921999 const globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true);
2200022000 if (globalPromiseType !== emptyGenericType) {
2200122001 // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type
22002- promisedType = getAwaitedType(promisedType) || emptyObjectType ;
22002+ promisedType = getAwaitedType(promisedType) || unknownType ;
2200322003 return createTypeReference(globalPromiseType, [promisedType]);
2200422004 }
2200522005
22006- return emptyObjectType ;
22006+ return unknownType ;
2200722007 }
2200822008
2200922009 function createPromiseLikeType(promisedType: Type): Type {
2201022010 // creates a `PromiseLike<T>` type where `T` is the promisedType argument
2201122011 const globalPromiseLikeType = getGlobalPromiseLikeType(/*reportErrors*/ true);
2201222012 if (globalPromiseLikeType !== emptyGenericType) {
2201322013 // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type
22014- promisedType = getAwaitedType(promisedType) || emptyObjectType ;
22014+ promisedType = getAwaitedType(promisedType) || unknownType ;
2201522015 return createTypeReference(globalPromiseLikeType, [promisedType]);
2201622016 }
2201722017
22018- return emptyObjectType ;
22018+ return unknownType ;
2201922019 }
2202022020
2202122021 function createPromiseReturnType(func: FunctionLikeDeclaration | ImportCall, promisedType: Type) {
2202222022 const promiseType = createPromiseType(promisedType);
22023- if (promiseType === emptyObjectType ) {
22023+ if (promiseType === unknownType ) {
2202422024 error(func, isImportCall(func) ?
2202522025 Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option :
2202622026 Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option);
@@ -23453,7 +23453,7 @@ namespace ts {
2345323453 // If the contextual type is a type variable constrained to a primitive type, consider
2345423454 // this a literal context for literals of that primitive type. For example, given a
2345523455 // type parameter 'T extends string', infer string literal types for T.
23456- const constraint = getBaseConstraintOfType(contextualType) || emptyObjectType ;
23456+ const constraint = getBaseConstraintOfType(contextualType) || unknownType ;
2345723457 return maybeTypeOfKind(constraint, TypeFlags.String) && maybeTypeOfKind(candidateType, TypeFlags.StringLiteral) ||
2345823458 maybeTypeOfKind(constraint, TypeFlags.Number) && maybeTypeOfKind(candidateType, TypeFlags.NumberLiteral) ||
2345923459 maybeTypeOfKind(constraint, TypeFlags.BigInt) && maybeTypeOfKind(candidateType, TypeFlags.BigIntLiteral) ||
0 commit comments