Skip to content

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

Closed

Description

@wangzishi

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.

Activity

  1. 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.[/+] on Jul 25, 2017
  2. 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.[/+] on Jul 25, 2017
  3. j-oliveras commented on Jul 25, 2017

    @j-oliveras
    Contributor
  4. DanielRosenwasser commented on Jul 26, 2017

    @DanielRosenwasser
    Member

    Duplicate of #12123.

  5. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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