Skip to content

Commit

Permalink
Expose method for retrieving inferred generic type arguments for a si…
Browse files Browse the repository at this point in the history
…gnature on the TypeChecker (microsoft#59637)
  • Loading branch information
tristanmenzel committed Jan 21, 2025
1 parent b78f466 commit 3e97a7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1931,8 +1931,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
isTypeParameterPossiblyReferenced,
typeHasCallOrConstructSignatures,
getSymbolFlags,
getTypeArgumentsForResolvedSignature,
};

function getTypeArgumentsForResolvedSignature(signature: Signature) {
if (signature.mapper === undefined) return undefined;
return instantiateTypes((signature.target || signature).typeParameters, signature.mapper);
}

function getCandidateSignaturesForStringLiteralCompletions(call: CallLikeExpression, editingArgument: Node) {
const candidatesSet = new Set<Signature>();
const candidates: Signature[] = [];
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5439,6 +5439,8 @@ export interface TypeChecker {
/** @internal */ typeHasCallOrConstructSignatures(type: Type): boolean;
/** @internal */ getSymbolFlags(symbol: Symbol): SymbolFlags;
/** @internal */ fillMissingTypeArguments(typeArguments: readonly Type[], typeParameters: readonly TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScriptImplicitAny: boolean): Type[];

getTypeArgumentsForResolvedSignature(signature: Signature): readonly Type[] | undefined;
}

/** @internal */
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6348,6 +6348,7 @@ declare namespace ts {
* and the operation is cancelled, then it should be discarded, otherwise it is safe to keep.
*/
runWithCancellationToken<T>(token: CancellationToken, cb: (checker: TypeChecker) => T): T;
getTypeArgumentsForResolvedSignature(signature: Signature): readonly Type[] | undefined;
}
enum NodeBuilderFlags {
None = 0,
Expand Down

0 comments on commit 3e97a7d

Please sign in to comment.