Skip to content

Assignability of functions with a rest parameter of an empty tuple possibly incorrect #25871

Closed
@bterlson

Description

@bterlson

TypeScript Version: 3.1.0-dev.20180722
Code

declare var f1: (... args: any[]) => void;

declare var f2: () => void;
declare var f3: (...args: []) => void;
declare var f4: (a: never) => void;

f1 = f2; // ok
f1 = f3; // error
f1 = f4; // error

Expected behavior:
I want to create function types that are assignable to f1 using tuple types ala f3. I expected f3 to behave more like f2 than f4.

Actual behavior:
f3 cannot be assigned to f2.

But adding any type into f3's args tuple makes the error go away.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions