Skip to content
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 a function that outputs the exact type #90

Closed
jandockx opened this issue Dec 31, 2020 · 1 comment · Fixed by #115
Closed

Add a function that outputs the exact type #90

jandockx opened this issue Dec 31, 2020 · 1 comment · Fixed by #115

Comments

@jandockx
Copy link

jandockx commented Dec 31, 2020

During debugging the d.ts files, it is often helpful to see the type TS inferred.

Now, I do this by writing temporarily

expectType<string>(expressionOfAComplexType)

This fails, and in the error message we see the type TS inferred, e.g.:

Argument of type { <T>(this: T, thisArg: any): T; <A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; <A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; <A0, A1, A2, A extends any[], R>(thi... is not assignable to parameter of type string.

That helps for "not to complex" types. But, as you can see, when the type becomes more complex, the output is shortened with ellipsis.

It would be nice to have a printType that we could use like

printType(expressionOfAComplexType)

that would print the complete type to stdout.

@BendingBender
Copy link
Collaborator

BendingBender commented Jun 1, 2021

@jandockx @sindresorhus @papb Would you mind testing my PR whether it is helpful for your use case or whether something is missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants