Skip to content

Inferred implicit any from constructor call #10978

Closed
@yortus

Description

@yortus

TypeScript Version: nightly 2.1.0-dev.20160918

Code

// @noImplicitAny: true
class M {
    constructor(fn: () => any) { }
}

const a = new M(() => a); // ERROR: 'a' implicitly has type 'any'...

Expected behavior:

No errors. Inferred type of a is M.

The expression new M(...) always has type M, it does not depend on the argument used in M's constructor.

Actual behavior:

Compiler error as shown in code comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions