Skip to content

(new CustomError) instanceof CustomError => false #833

@ken0x0a

Description

@ken0x0a

Maybe related to #583

(new CustomError) instanceof CustomError
// => false 
// should be `true` but will get `false` @ ts-node
// `true` @ node

In addition, constructor also works unexpectedly.

(new WithoutConstructorError).constructor === WithoutConstructorError // => false
(new WithoutConstructorError).constructor === Error // => true

I've tested using following code.
Adding constructor in class did not change result.

class WithoutConstructorError extends Error {}

(new Error).name
(new WithoutConstructorError).name

(new Error) instanceof Error
(new Error) instanceof WithoutConstructorError
(new WithoutConstructorError) instanceof WithoutConstructorError
(new WithoutConstructorError) instanceof Error

(new Error).constructor === Error
(new Error).constructor === WithoutConstructorError
(new WithoutConstructorError).constructor === WithoutConstructorError
(new WithoutConstructorError).constructor === Error

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions