Skip to content

Native API: expose inferred type arguments of a resolved signatureΒ #65424

Open

Description

πŸ” Search Terms

getTypeArgumentsForResolvedSignature, inferred type arguments, resolved signature, signature mapper, native API, missing checker methods, API parity

βœ… Viability Checklist

⭐ Suggestion

Expose the inferred type arguments of a resolved call through the native API client. This is missing in typescript@7.1.0-dev.20261109.1; the API comparison report in #64749 also lists getTypeArgumentsForResolvedSignature as missing.

The JavaScript checker already exposes this operation through #59637 and #60201. The same shape would work on the native client's Checker:

// typescript/sync
getTypeArgumentsForResolvedSignature(signature: Signature): readonly Type[] | undefined;

// typescript/async
getTypeArgumentsForResolvedSignature(signature: Signature): Promise<readonly Type[] | undefined>;

The returned types would be client Type objects backed by handles, in the original type-parameter order, with the same semantics as the existing JavaScript-checker method.

πŸ“ƒ Motivating Example

interface Order {
    id: string;
}
declare const order: Order;
declare function parse<T>(value: T): void;

parse(order); // inferred type arguments: [Order]

Given the call node, checker.getResolvedSignature(call) resolves the instantiated signature, but signature.getTypeParameters() does not return [Order]. signature.getTarget() gives access to the original signature, without the mapping from T to Order. checker.getTypeArguments() accepts a type reference rather than a signature.

The proposed method would return the type for Order for this call, including when the return type does not mention T.

πŸ’» Use Cases

We maintain a compiler plugin that records the type arguments of generic calls, including arguments inferred by the checker. We need the resolved substitution (T = Order), rather than the original type parameter or the value argument's type. The native checker retains that substitution in its signature mapper, but no API operation returns it. Today we rebuild it by matching the instantiated signature against its target, which repeats work the checker has already done and can drift from its inference. Filing it separately since #64709 is triaging missing checker methods before stable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Suggestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions