Skip to content

Decorator overview

All decorators are exported from lombok-typescript/legacy and lombok-typescript/stage3.

Phase 1 (v0.1)

DecoratorKindCodegen?Summary
@NonNullRuntime fieldNoReject null / undefined on assignment
@ToStringCodegenYesGenerated toString()
@BuilderCodegenYesFluent builder class
@DataCodegen compositeYesGetters, setters, equals, toString
@SingletonRuntime classNoSingle shared instance per class
@PrototypeRuntime classNoNew instance on every new
@FactoryHybridPartialNamed factory registry
@MemoizeRuntime methodNoCache method results by arguments

Phase 2 (v0.2.0–0.4.0)

DecoratorKindCodegen?Summary
@ValueCodegen compositeYesImmutable @Data + with*
@WithCodegenYesPer-field immutable copy helpers
@EqualsCodegenYesStructural equals + static helper
@Getter / @SetterCodegen fieldYesSingle-field accessors
@LogRuntimeNoMethod entry logging
@AccessorsCodegen metadataYesFluent/chained setter style
@UtilityClassRuntimeNoUninstantiable utility holder
@FieldDefaultsCodegen metadataYesDefault readonly for generated code
@DelegateCodegen fieldYesForward methods to a field

@Data and @Value cannot be combined — codegen enforces this at generation time.

Phase 3 (v0.5.0–v0.6.0)

DecoratorKindCodegen?Summary
@StrategyHybridNoTwo-level algorithm registry
@State / @TransitionRuntimeNoFinite state machine
@CommandRuntimeNoCommand objects + undo stack
@MementoRuntimeNoSnapshot / restore
@ObservableRuntimeNoReactive property subscriptions
@ChainOfResponsibilityRuntimeNoOrdered handler chain
@IterableRuntimeNoSymbol.iterator over a field

Observer adapters: RxJS / MobX.

Phase 4a (v0.7.0)

DecoratorKindCodegen?Summary
@FlyweightRuntimeNoInstance pool keyed by constructor
@ProxyHybrid (runtime)NoMethod before/after hooks
@CompositeRuntimeShimTree add/remove/traverse API

Phase 4b (v0.8.0)

DecoratorKindCodegen?Summary
@WrapsRuntimeShimGoF Decorator — inner delegation
@TemplateMethod / @HookCodegen + metadataYesOrdered template method steps
@AbstractFactoryCodegen HelperYesAbstract product factory stubs
@Visitor / @VisitableHybridYesDouble-dispatch accept(visitor)

Phase 5 (v0.9.0)

DecoratorKindCodegen?Summary
@RetryRuntime methodNoAsync retry with backoff
@Debounce / @ThrottleRuntime methodNoDebounce or throttle invocations
@TraceRuntimeNoMethod entry/exit logging
@DeepFreezeRuntime classNoRecursive Object.freeze on new
@ValidateHybridPartialZod/Yup/class-validator adapters
@SerializableHybridYestoJSON / fromJSON codegen

Validator adapters: lombok-typescript/validators/{zod,yup,class-validator} (optional peer deps).

Phase 6 (v0.10.0) — Marker-only

Complete GoF coverage with metadata-only decorators (no codegen).

DecoratorKindCodegen?Summary
@AdapterMarker classNoDocuments API adapter intent
@BridgeMarker classNoAbstraction / implementation split
@FacadeMarker classNoSubsystem simplification
@MediatorMarker classNoColleague coordination role
@InterpreterMarker classNoDSL / grammar interpreter role

@Adapter (GoF) is unrelated to ValidatorAdapter in the validators subpath exports.

Codegen decorators

Run after changing decorated classes:

bash
lombok-ts generate
# or watch for changes:
lombok-ts watch

Then call applyAllGenerated (or per-class apply*Generated) from the .lombok.ts companion.

Choosing a backend

ts
// Legacy
import { Data, Value } from 'lombok-typescript/legacy';

// Stage 3
import { Data, Value } from 'lombok-typescript/stage3';

See Getting started for tsconfig requirements.

Released under the MIT License.