Skip to content

Parameters<> does not support optional params #9125

Open
@ayroblu

Description

declare type F = (s: string, n?: number) => boolean;
type Tuple = Parameters<F>;
declare function g(...args: Parameters<F>): boolean;
g("hi")

Cannot call g because rest array [1] has 1 element but tuple type [2] has 2 elements. [invalid-tuple-arity]

Flow version: master

Expected behavior

Type is tuple with optional arity

Actual behavior

Tuple is fixed length

Metadata

Assignees

Labels

Typing: completenessNo false positives (type checker claims that there are some errors in the correct program)bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions