Skip to content

Commit dd2c1cd

Browse files
committed
Expose method for retrieving inferred generic type arguments for a signature on the TypeChecker (microsoft#59637)
1 parent a53c37d commit dd2c1cd

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,8 +1927,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
19271927
isTypeParameterPossiblyReferenced,
19281928
typeHasCallOrConstructSignatures,
19291929
getSymbolFlags,
1930+
getTypeArgumentsForResolvedSignature,
19301931
};
19311932

1933+
function getTypeArgumentsForResolvedSignature(signature: Signature) {
1934+
if (signature.mapper === undefined) return undefined
1935+
return instantiateTypes((signature.target || signature).typeParameters, signature.mapper);
1936+
}
1937+
19321938
function getCandidateSignaturesForStringLiteralCompletions(call: CallLikeExpression, editingArgument: Node) {
19331939
const candidatesSet = new Set<Signature>();
19341940
const candidates: Signature[] = [];

src/compiler/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5426,6 +5426,8 @@ export interface TypeChecker {
54265426
/** @internal */ typeHasCallOrConstructSignatures(type: Type): boolean;
54275427
/** @internal */ getSymbolFlags(symbol: Symbol): SymbolFlags;
54285428
/** @internal */ fillMissingTypeArguments(typeArguments: readonly Type[], typeParameters: readonly TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScriptImplicitAny: boolean): Type[];
5429+
5430+
getTypeArgumentsForResolvedSignature(signature: Signature): readonly Type[] | undefined
54295431
}
54305432

54315433
/** @internal */

tests/baselines/reference/api/typescript.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6349,6 +6349,7 @@ declare namespace ts {
63496349
* and the operation is cancelled, then it should be discarded, otherwise it is safe to keep.
63506350
*/
63516351
runWithCancellationToken<T>(token: CancellationToken, cb: (checker: TypeChecker) => T): T;
6352+
getTypeArgumentsForResolvedSignature(signature: Signature): readonly Type[] | undefined;
63526353
}
63536354
enum NodeBuilderFlags {
63546355
None = 0,

0 commit comments

Comments
 (0)