@typescript-plus/builtin-class-decorator
v0.4.0
Published
A TypeScript class decorator for extending builtin classes in ES5.
Downloads
2
Readme
Builtin Class Decorator
A TypeScript class decorator for extending builtin classes in ES5.
Install
$ npm i @typescript-plus/builtin-class-decorator --save
Summary
When the compile target is es5
, to correctly extend the builtin classes, such as Array, Map and Error, you need to do this workaround.
With Builtin Class Decorator, you can simply do it.
Usage
import { Es5BuiltinClass } from '@typescript-plus/builtin-class-decorator';
@Es5BuiltinClass()
class SpecialError extends Error {
constructor() {
super();
}
}
const error = new SpecialError();
error instanceof Error; // true
error instanceof SpecialError; // true