We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I found alternative solution on stack overflow but was advised to open an issue here
TypeScript Version: 3.8.3
Search Terms: ReturnType Parameters Function any never
Code
const abc = (a:never):number=>1 type a = ReturnType< typeof abc> //any const abc2 = (a:number, b:never):number=>1 type a2 = ReturnType< typeof abc2> //any
Expected behavior: type a and a2 should be number regardless of the types of parameters
a
a2
number
Actual behavior: type a and a2 are any if any of the types of the parameters are never
any
never
Playground link
the original question is posted on here with details describing the use case link
The text was updated successfully, but these errors were encountered:
This is interesting:
type Expected = ((arg: string) => 0) extends (...args: any) => infer R ? "expected" : "unexpected"; // expected type Unexpected = ((arg: never) => 0) extends (...args: any) => infer R ? "expected" : "unexpected"; // unexpected type Expected2 = ((arg: never) => 0) extends (...args: any) => any ? "expected" : "unexpected"; // expected type Unexpected2 = ((arg: never) => 0) extends ((...args: any) => 0) ? "expected" : "unexpected" // unexpected
There's probably an existing issue for this but I didn't see one.
Sorry, something went wrong.
Duplicate of #35432.
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
I found alternative solution on stack overflow but was advised to open an issue here
TypeScript Version: 3.8.3
Search Terms:
ReturnType
Parameters
Function
any
never
Code
Expected behavior:
type
a
anda2
should benumber
regardless of the types of parametersActual behavior:
type
a
anda2
areany
if any of the types of the parameters arenever
Playground
link
the original question is posted on here with details describing the use case
link
The text was updated successfully, but these errors were encountered: