Skip to content

Wrong constructor of Error subclass from 2.1.1 #12660

Closed
@marty-wang

Description

@marty-wang

TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)

Code

// A *self-contained* demonstration of the problem follows...
class MyError extends Error {
    public code: number;
    constructor(code: number, message: string) {
        super(message);
        this.code = code;
    }
}

const e = new MyError(0, "foo");

Expected behavior:
e instanceof MyError === true;
Actual behavior:
e instanceof MyError === false

Note: it was working for ts 2.0.10, but not for ts 2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions