Skip to content

Bug? Closure arguments not checked for variable number of arguments #2506

Closed
@mindplay-dk

Description

@mindplay-dk

Example:

class Biff {}
class Bang {}

interface Callback {
    (...biffs: Biff[]);
}

function foo(callback: Callback) {
    callback(new Biff(), new Biff());
}

foo((x: Biff, y: Bang) => console.log('whoa'));

foo((z: string, n: number) => console.log('huh'));

The closures passed as arguments in the two calls at the end, do not appear to get type-checked.

It's pretty plain that these closures will not be invoked with suitable arguments, yet the code appears to compile with no complaints.

How come this doesn't get type-checked?

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions