Skip to content

@litert/decorator

Utilities for ECMAScript/TypeScript, to create decorators easily and effectively.

Installation

sh
npm install @litert/decorator

Quick Start

ts
import { Methods, getMetadataContainer } from '@litert/decorator';

const myDecorator = Methods.withArgsCheck((_method, ctx) => {
    ctx.metadata!['myDecorator'] = true;
});

class DemoClass {
    @myDecorator
    public list(): void {}
}

What it is

@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.

Why use it

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.

Entrypoints

Import pathUse it for
@litert/decoratorModern TypeScript standard decorators and metadata helpers.
@litert/decorator/legacyLegacy TypeScript experimental decorators.
@litert/decorator/compatibleDecorators shared by modern and legacy builds.