@@ -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,25 @@ 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',
87068718 // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter.
8719+ // FIXME: this needs to be updated to address new behavior with inferInstanceTypeArgumentsAsConstraint
87078720 // 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 ;
8721+ const classSymbol = getParentOfSymbol(prototype)!;
8722+ return getInstanceTypeOfClassSymbol(classSymbol) ;
87108723 }
87118724
87128725 // Return the type of the given property in the given type, or undefined if no such property exists
@@ -25135,10 +25148,10 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
2513525148 if (symbol === undefined) {
2513625149 return type;
2513725150 }
25138- const classSymbol = symbol.parent !;
25151+ const classSymbol = getParentOfSymbol( symbol) !;
2513925152 const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
2514025153 ? getTypeOfSymbol(classSymbol) as InterfaceType
25141- : getDeclaredTypeOfSymbol (classSymbol);
25154+ : getInstanceTypeOfClassSymbol (classSymbol);
2514225155 return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
2514325156 }
2514425157
0 commit comments