Skip to content
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

Can't get correct instance type when extending from Error and target es5. #17398

Closed
wangzishi opened this issue Jul 25, 2017 · 2 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@wangzishi
Copy link

TypeScript Version: 2.4.2

Code

class MyError extends Error {
    constructor(msg: any) {
        super(msg);
    }
}

let err = new MyError('msg');

console.log(err instanceof MyError);

Expected behavior:
true

Actual behavior:
err instanceof MyError return false, and err is an instance of Error.

@wangzishi wangzishi changed the title Can't get correct instance type when extending from Error. Can't get correct instance type when extending from Error when target es5. Jul 25, 2017
@wangzishi wangzishi changed the title Can't get correct instance type when extending from Error when target es5. Can't get correct instance type when extending from Error and target es5. Jul 25, 2017
@j-oliveras
Copy link
Contributor

This is a breaking change since Typescript 2.1.

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Jul 26, 2017
@DanielRosenwasser
Copy link
Member

Duplicate of #12123.

@DanielRosenwasser DanielRosenwasser marked this as a duplicate of #12123 Jul 26, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 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

3 participants