-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
Bug Report
The system Error class cannot be extended without calling Object.setPrototypeOf() as a workaround, like this:
class FooError extends Error {
constructor(m: string) {
super(m);
// Set the prototype explicitly.
Object.setPrototypeOf(this, FooError.prototype);
}
}The TypeScript 2.1 release notes imply that this behavior is by design.
However when I proposed to implement this workaround in the ANTLR4 runtime library, they observed that Babel injects the workaround automatically. Thus they concluded that this is a TypeScript bug rather than a problem with their library.
Is there some reason why TypeScript's transpiler cannot use the same solution as Babel?
🔎 Search Terms
setPrototypeOf extends Error
🕗 Version & Regression Information
Repros in TypeScript 4.1.3, first introduced in TypeScript 2.1.0
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code