Modern decorator supports
Build standard decorators (stage 3) with target checks, composition helpers, and metadata access.
Utilities for ECMAScript/TypeScript, to create decorators easily and effectively.
npm install @litert/decoratorimport { Methods, getMetadataContainer } from '@litert/decorator';
const myDecorator = Methods.withArgsCheck((_method, ctx) => {
ctx.metadata!['myDecorator'] = true;
});
class DemoClass {
@myDecorator
public list(): void {}
}@litert/decorator is a focused utility library for writing decorators in TypeScript. It does not provide application-level decorators such as routing, dependency injection, or validation decorators. Instead, it helps you build those decorators with less boilerplate around decorator signatures.
Decorator callback signatures differ by transform and by target kind. A class decorator, method decorator, property decorator, static member decorator, and legacy parameter decorator all receive different argument shapes.
This library provides checked helpers for those shapes, normalized legacy contexts, composition utilities, modern metadata helpers, and a compatible layer for code that needs to support both TypeScript decorator transforms.
| Import path | Use it for |
|---|---|
@litert/decorator | Modern TypeScript standard decorators and metadata helpers. |
@litert/decorator/legacy | Legacy TypeScript experimental decorators. |
@litert/decorator/compatible | Decorators shared by modern and legacy builds. |