Timeline for What's a good way to extend Error in JavaScript?
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 25, 2021 at 14:00 | comment | added | ericP |
To clarify @maxime1992's day-saving comment, ES3 and ES5 fail; anything from ES2015 on preserves the CustomError prototype as expected. Of course, CustomError is also instanceof Error so tests should test for the most specific class.
|
|
Aug 23, 2021 at 19:39 | comment | added | KFunk | Seems to be working as expected in TS 4.3.5: typescriptlang.org/play?#code/… | |
May 16, 2021 at 9:40 | comment | added | bluenote10 |
Yes, I can only reproduce this issue when using target: "es5" .
|
|
May 16, 2021 at 9:26 | comment | added | maxime1992 | Unsure, you'd have to test it ;) | |
May 16, 2021 at 9:05 | comment | added | bluenote10 |
Does that mean that whether this workaround is needed In a NodeJS context depends on the target setting in tsconfig.json ? If the target is es5 it is needed because the transpilation would lose the correct proto information otherwise. If the target is es6 and newer, the transpilation keeps the class syntax, and NodeJS will handle it as expected without any workarounds?
|
|
Feb 1, 2018 at 16:34 | history | answered | maxime1992 | CC BY-SA 3.0 |