Skip to content

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

Merged
ahejlsberg merged 4 commits into
masterfrom
fixParametersAndReturnType
Feb 4, 2019
Merged

Less restrictive Parameters<T> and ReturnType<T>#29705
ahejlsberg merged 4 commits into
masterfrom
fixParametersAndReturnType

Conversation

@ahejlsberg
Copy link
Copy Markdown
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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants