Skip to content

Parameters<...> type check fails with generators #28803

Closed
@aikoven

Description

@aikoven

TypeScript Version: 3.2.0-dev.201xxxxx

Search Terms:

generic rest generators

Code

declare function call<Fn extends (...args: any[]) => any>(
    fn: Fn,
    ...args: Parameters<Fn>
): any

call((a: 'a') => {})
call(function*(a: 'a') {})

Expected behavior:

call with generator type checks the same way as with plain function i.e. gives type error when args are missing

Actual behavior:

call gives type error when args are missing with plain function, but not with generator

Playground Link:

http://www.typescriptlang.org/play/#src=declare%20function%20call%3CFn%20extends%20(...args%3A%20any%5B%5D)%20%3D%3E%20any%3E(%0D%0A%20%20%20%20fn%3A%20Fn%2C%0D%0A%20%20%20%20...args%3A%20Parameters%3CFn%3E%0D%0A)%3A%20any%0D%0A%0D%0Acall((a%3A%20'a')%20%3D%3E%20%7B%7D)%0D%0Acall(function*(a%3A%20'a')%20%7B%7D)

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Conditional TypesThe issue relates to conditional typesDomain: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolution

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions