-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add typeChecker API to get the inferred type arguments of call expression #59637
Comments
We don't have a function for this internally (weird, I know - we always operate over and compose function getTypeArgumentsForResolvedSignature(signature: Signature) {
return instantiateTypes((signature.target || signature).typeParameters, signature.mapper);
} (so long as you're OK with an unresolved signature returning its' input type parameter list). You can't implement it publicly because |
Approved to expose the above function |
I have the following use case of the type checker public API. Is that impossible since
|
TL; DR: How can I use TypeScript's type checker API to determine if a |
…gnature on the TypeChecker (microsoft#59637)
…gnature on the TypeChecker (microsoft#59637)
🔍 Search Terms
infer type arguments function call expression
✅ Viability Checklist
⭐ Suggestion
📃 Motivating Example
For the below code, the proposed API is supposed to return
[ "text" ]
for thePassthrough("text")
node.💻 Use Cases
In my own case, I'm writing a TypeScript to C++ compiler and getting the inferred type argument is essential for translating the generic function call to C++.
There are also a few other open source projects getting the information by hacking TypeScript's internals:
https://github.com/GoogleFeud/ts-macros/blob/e65480a7bc54107e935e9a95ecbb4f3825f2d6e2/src/utils.ts#L259-L270
https://github.com/mxsdev/ts-type-explorer/blob/3b0bb21f574ebb0d70aac84c37e81e1df0b1d9e4/packages/api/src/util.ts#L725-L750
https://github.com/johnW-ret/express-openapi-gen/blob/885e498066f51fccaa00615f0b46b070788477c9/src/index.ts#L45C18-L84
The text was updated successfully, but these errors were encountered: