We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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.
true
Actual behavior: if compiled with TypeScript and then ran in browser/node environment prints false but if ran without compilation prints true.
false
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:
The text was updated successfully, but these errors were encountered:
https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
Duplicate of #12123
Sorry, something went wrong.
https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work
No branches or pull requests
TypeScript Version: 3.0.0-dev.201xxxxx
Search Terms: error inheritance
Code
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 printstrue
.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:
The text was updated successfully, but these errors were encountered: