Skip to content

Type for done not inferred #5

@felixfbecker

Description

@felixfbecker

The way how it is defined as a callable ITestDefinition interface makes it impossible for TS to infer the type of the done callback.

 declare var it: Mocha.ITestDefinition;
 interface ITestDefinition {
        (expectation: string, assertion?: () => void): ITest;
        (expectation: string, assertion?: (done: MochaDone) => void): ITest;
        only(expectation: string, assertion?: () => void): ITest;
        only(expectation: string, assertion?: (done: MochaDone) => void): ITest;
        skip(expectation: string, assertion?: () => void): void;
        skip(expectation: string, assertion?: (done: MochaDone) => void): void;
        timeout(ms: number): void;
    }

Doing

it('whatever', done => {

});

yields

src/test/dbgp.ts(24,53): error TS7006: Parameter 'done' implicitly has an 'any' type.

This used to work. Now we have to do

it('whatever', (done: MochaDone) => {

});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions