swc/tests/fixture/new-target/input/class-extends-error.ts

6 lines
214 B
TypeScript

class CustomError extends Error {
constructor(message?: string) {
super(message); // 'Error' breaks prototype chain here
Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain
}
}