JS: Recognize type vars on anonymous function types

This commit is contained in:
Asger F
2023-04-25 11:08:06 +02:00
parent ff67118097
commit cab76507e7

View File

@@ -533,7 +533,7 @@ export class TypeTable {
let enclosingType = getEnclosingTypeOfThisType(type);
if (enclosingType != null) {
return "this;" + this.getId(enclosingType, false);
} else if (symbol.parent == null) {
} else if (symbol.parent == null || isFunctionTypeOrTypeAlias(symbol.declarations?.[0])) {
// The type variable is bound on a call signature. Only extract it by name.
return "lextypevar;" + symbol.name;
} else {
@@ -1328,3 +1328,8 @@ export class TypeTable {
}
}
}
function isFunctionTypeOrTypeAlias(declaration: ts.Declaration | undefined) {
if (declaration == null) return false;
return declaration.kind === ts.SyntaxKind.FunctionType || declaration.kind === ts.SyntaxKind.TypeAliasDeclaration;
}