Skip to content

instanceof is broken when class extends Error type #13965

@tikurahul

Description

@tikurahul

TypeScript Version: 2.1.1

class BaseError extends Error {}
class Error1 extends BaseError {}

let error = new Error1();
console.log(error instanceof Error1);

Expected behavior:
prints true.

Actual behavior:
prints false.

Note:
This happens only when a type extends Error.
After removing extends Error from BaseError everything works as expected.

Links
Test case

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