Skip to content

Commit cab7650

Browse files
committed
JS: Recognize type vars on anonymous function types
1 parent ff67118 commit cab7650

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

javascript/extractor/lib/typescript/src/type_table.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ export class TypeTable {
533533
let enclosingType = getEnclosingTypeOfThisType(type);
534534
if (enclosingType != null) {
535535
return "this;" + this.getId(enclosingType, false);
536-
} else if (symbol.parent == null) {
536+
} else if (symbol.parent == null || isFunctionTypeOrTypeAlias(symbol.declarations?.[0])) {
537537
// The type variable is bound on a call signature. Only extract it by name.
538538
return "lextypevar;" + symbol.name;
539539
} else {
@@ -1328,3 +1328,8 @@ export class TypeTable {
13281328
}
13291329
}
13301330
}
1331+
1332+
function isFunctionTypeOrTypeAlias(declaration: ts.Declaration | undefined) {
1333+
if (declaration == null) return false;
1334+
return declaration.kind === ts.SyntaxKind.FunctionType || declaration.kind === ts.SyntaxKind.TypeAliasDeclaration;
1335+
}

0 commit comments

Comments
 (0)