-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Wrong typescript definition for serializeError #79
Comments
No...
According to this test, yes we do.
There's nothing wrong with input type and return type not sharing the same type. |
@papb What I wanted to say is that the current type definition is wrong https://github.com/sindresorhus/serialize-error/blob/main/index.d.ts#L108 Type definition is enforcing that the return value should have the same type of the input, while we convert function inputs to string |
That is correct. Lines 141 to 166 in 2a77169
The logic is simply:
The return is never |
If I am understanding the TypeScript correctly,
https://www.typescriptlang.org/docs/handbook/2/generics.html#working-with-generic-type-variables
https://github.com/sindresorhus/serialize-error/blob/main/index.js#L160
If the value input is function,
Should the type of return value must be also function as well?
If we still want to convert function value to string,
The type definition for input & return value should be
any
orunknown
since they don't share the same type.The text was updated successfully, but these errors were encountered: