@@ -383,6 +383,7 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
383383 const noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
384384 const noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
385385 const useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
386+ const inferInstanceTypeArgumentsAsConstraint = getStrictOptionValue(compilerOptions, "inferInstanceTypeArgumentsAsConstraint");
386387 const keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
387388 const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral;
388389 const exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes;
@@ -8700,13 +8701,24 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
87008701 })!.parent;
87018702 }
87028703
8704+ function getInstanceTypeOfClassSymbol(classSymbol: Symbol): Type {
8705+ const classType = getDeclaredTypeOfSymbol(classSymbol) as InterfaceType;
8706+ if (!classType.typeParameters) {
8707+ return classType;
8708+ }
8709+ const typeArguments = map(classType.typeParameters, typeParameter => {
8710+ return (inferInstanceTypeArgumentsAsConstraint) ? getBaseConstraintOfType(typeParameter) || unknownType : anyType;
8711+ });
8712+ return createTypeReference(classType as GenericType, typeArguments);
8713+ }
8714+
87038715 function getTypeOfPrototypeProperty(prototype: Symbol): Type {
87048716 // TypeScript 1.0 spec (April 2014): 8.4
87058717 // Every class automatically contains a static property member named 'prototype',
8706- // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter .
8718+ // the type of which is an instantiation of the class type.
87078719 // It is an error to explicitly declare a static property member with the name 'prototype'.
8708- const classType = getDeclaredTypeOfSymbol( getParentOfSymbol(prototype)!) as InterfaceType ;
8709- return classType.typeParameters ? createTypeReference(classType as GenericType, map(classType.typeParameters, _ => anyType)) : classType ;
8720+ const classSymbol = getParentOfSymbol(prototype)!;
8721+ return getInstanceTypeOfClassSymbol(classSymbol) ;
87108722 }
87118723
87128724 // Return the type of the given property in the given type, or undefined if no such property exists
@@ -25135,10 +25147,10 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
2513525147 if (symbol === undefined) {
2513625148 return type;
2513725149 }
25138- const classSymbol = symbol.parent !;
25150+ const classSymbol = getParentOfSymbol( symbol) !;
2513925151 const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
2514025152 ? getTypeOfSymbol(classSymbol) as InterfaceType
25141- : getDeclaredTypeOfSymbol (classSymbol);
25153+ : getInstanceTypeOfClassSymbol (classSymbol);
2514225154 return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
2514325155 }
2514425156
0 commit comments