-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Better ReturnType<>; Fixes Microsoft/TypeScript#33457 #33496
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
Conversation
It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src'. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src'. |
1 similar comment
It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src'. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src'. |
Oh. TS bot sent me a warning. Should I close this and open a PR with |
It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src'. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src'. |
Related, The type parameter constraint and RHS of conditional type I'm using are different because of the issue outlined there. Also, is TS bot borked or is it supposed to say that after every comment? |
It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src'. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src'. |
1 similar comment
It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src'. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src'. |
It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src'. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src'. |
64e9cb3
to
15737c2
Compare
@weswigham just thought I'd show you that the TS bot hated it when I touched |
@@ -1466,7 +1466,7 @@ type ConstructorParameters<T extends new (...args: any) => any> = T extends new | |||
/** | |||
* Obtain the return type of a function type | |||
*/ | |||
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any; | |||
type ReturnType<T extends (...args: any) => any> = T extends (...args: never) => infer R ? R : any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ReturnType
generic parameter constraint needs to be changed too.
Also, try using never[]
instead of just never
, maybe that helps.
TypeScript/src/compiler/core.ts Line 1464 in c447ebc
I'd just like to point out that export type AnyFunction = (...args: never[]) => void;
//Expected: void
//Actual: any
type x = ReturnType<AnyFunction>; |
This PR hasn't seen any activity for quite a while, so I'm going to close it to keep the number of open PRs manageable. Feel free to open a fresh PR or continue the discussion on one of the linked bugs. |
Please verify that:
Backlog
milestone (required)master
branchgulp runtests
locallyFixes #33457
There's no issue in the
Backlog
but I figured I'd try anyway =xIt fixes my issue and only affects one other test.
But that one other test seems to only have its type emit affected?
is emitted as,
But when a concrete
T
is substituted in, it resolves toT[]