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

Error inheritance bug #25383

Closed
elderapo opened this issue Jul 3, 2018 · 2 comments
Closed

Error inheritance bug #25383

elderapo opened this issue Jul 3, 2018 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@elderapo
Copy link

elderapo commented Jul 3, 2018

TypeScript Version: 3.0.0-dev.201xxxxx

Search Terms: error inheritance

Code

class CustomError extends Error {}

try {
  throw new CustomError();
} catch (ex) {
  console.log(ex instanceof CustomError);
}

Expected behavior: should print true in both TypeScript and vanilla JS.

Actual behavior: if compiled with TypeScript and then ran in browser/node environment prints false but if ran without compilation prints true.

Playground Link: http://www.typescriptlang.org/play/#src=class%20CustomError%20extends%20Error%20%7B%7D%0D%0A%0D%0Atry%20%7B%0D%0A%20%20throw%20new%20CustomError()%3B%0D%0A%7D%20catch%20(ex)%20%7B%0D%0A%20%20console.log(ex%20instanceof%20CustomError)%3B%0D%0A%7D%0D%0A

Related Issues:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants