@@ -383,6 +383,7 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
383
383
const noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
384
384
const noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
385
385
const useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
386
+ const inferInstanceTypeArgumentsAsConstraint = getStrictOptionValue(compilerOptions, "inferInstanceTypeArgumentsAsConstraint");
386
387
const keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
387
388
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral;
388
389
const exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes;
@@ -8700,13 +8701,25 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
8700
8701
})!.parent;
8701
8702
}
8702
8703
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
+
8703
8715
function getTypeOfPrototypeProperty(prototype: Symbol): Type {
8704
8716
// TypeScript 1.0 spec (April 2014): 8.4
8705
8717
// Every class automatically contains a static property member named 'prototype',
8706
8718
// 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
8707
8720
// 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) ;
8710
8723
}
8711
8724
8712
8725
// 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")
25135
25148
if (symbol === undefined) {
25136
25149
return type;
25137
25150
}
25138
- const classSymbol = symbol.parent !;
25151
+ const classSymbol = getParentOfSymbol( symbol) !;
25139
25152
const targetType = hasStaticModifier(Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
25140
25153
? getTypeOfSymbol(classSymbol) as InterfaceType
25141
- : getDeclaredTypeOfSymbol (classSymbol);
25154
+ : getInstanceTypeOfClassSymbol (classSymbol);
25142
25155
return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
25143
25156
}
25144
25157
0 commit comments