Files
scriptc/tests/diagnostics/error-header-accessor-fences.ts
T
2026-10-20 12:55:55 -05:00

16 lines
502 B
TypeScript

// Inspecting an Error subclass instance renders its header from the
// instance's own name and message. A program class that declares a `name`,
// `message` or `stack` accessor changes what Node reads, so inspecting the
// hierarchy has no lowering.
import * as util from "node:util";
class Named extends Error {
override get name(): string {
return "Custom";
}
}
class Deeper extends Named {}
console.log(util.inspect(new Named("accessor")));
console.log(new Deeper("inherited accessor"));