Skip to content

instanceof doesn't work for extended builtin types #12145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hbakhtiyor opened this issue Nov 10, 2016 · 3 comments
Closed

instanceof doesn't work for extended builtin types #12145

hbakhtiyor opened this issue Nov 10, 2016 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@hbakhtiyor
Copy link

TypeScript Version: 1.8.7

Code

export class CustomError extends Error {
    name = "CustomError";

    constructor() {
        super();
        this.message = "message";
    }
}
const err = new CustomError();
console.log(err instanceof CustomError); // => false
@vknez
Copy link

vknez commented Nov 16, 2016

I have the same issue with TypeScript 2.1.1.

@vknez
Copy link

vknez commented Nov 16, 2016

Apparently, there are other issues referencing the same, i.e. #12279, #12123, #12058.

@DanielRosenwasser
Copy link
Member

I'm marking this as a duplicate of #12123. This is an intentional breaking change and documented here. Sorry about the inconveniences due to this change.

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Dec 6, 2016
@mhegazy mhegazy closed this as completed Dec 6, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants