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

Less restrictive Parameters<T> and ReturnType<T> #29705

Merged
merged 4 commits into from
Feb 4, 2019

Conversation

ahejlsberg
Copy link
Member

This PR changes the constraints of the predefined Parameters<T>, ConstructorParameters<T>, ReturnType<T> and InstanceType<T> from

T extends (...args: any[]) => any

to the less restrictive

T extends (...args: any) => any

With this change, the types can be applied to functions that themselves have generic rest parameters. For example:

type Foo<T extends any[]> = ReturnType<(...args: T) => string>;  // string

Previously, this was an error.

Fixes #26856.

@ahejlsberg ahejlsberg merged commit f86b635 into master Feb 4, 2019
@ahejlsberg ahejlsberg deleted the fixParametersAndReturnType branch February 4, 2019 20:08
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 this pull request may close these issues.

2 participants