Skip to content

From Java Lombok

A reference for Java developers moving to Node / TypeScript. Each common Lombok annotation maps to a lombok-typescript equivalent, a TypeScript-native workaround, or a clearly-labeled planned feature.

Annotation map

Java Lomboklombok-typescriptNotes
@Data@DataCodegen + applyAllGenerated
@Value@ValueImmutable; readonly fields. Closest to a Java record
@Builder@BuilderClass.builder() fluent API
@SuperBuilder@BuilderSingle-level today; inheritance builders planned (Phase 9)
@Builder.Default@BuilderDefaultKeeps the field initializer when the builder omits the field
@Singular@SingularAccumulator builder methods (role()/roles()/clearRoles()) for array fields
@Getter / @Setter@Getter / @SetterCodegen
@Getter(lazy = true)@MemoizeCaches the computed value on first access
@ToString@ToStringCodegen toString()
@EqualsAndHashCode@EqualsGenerates equals() + toHash() (TS name for Java's hashCode())
@With@WithImmutable withX() codegen
@Accessors@AccessorsFluent / chained accessor style
@Delegate@DelegateForward methods to a delegate field
@FieldDefaults@FieldDefaultsDefault field visibility / readonly
@UtilityClass@UtilityClassStatic-only holder
@Slf4j / @Log@Log (or @LogNest for NestJS)BYOL logger adapters
@NonNull@NonNullRuntime null checks
@NoArgsConstructor / @AllArgsConstructorNot needed — use @Builder, field initializers, or object literals
@RequiredArgsConstructorNest constructor DIIn NestJS, @Injectable() classes get constructor injection natively
@SneakyThrowsNot needed — TypeScript has no checked exceptions
@CleanupUse try/finally or using (TS 5.2 explicit resource management)
@Synchronizedplanned (Phase 12); JS is single-threaded, so rarely needed

Workflow differences

  1. Run lombok-ts generate for codegen decorators (@Data, @Builder, @Getter, …).
  2. Call applyAllGenerated() at startup (see Getting started).
  3. Choose legacy decorators for NestJS (experimentalDecorators: true), or stage3 for TS 6.0+ without experimentalDecorators.

Unlike Java, where annotations are processed at compile time by the Lombok agent, lombok-typescript splits the work: codegen decorators emit companion files via the CLI, while runtime decorators (@Memoize, @Retry, @Log, …) wrap behavior directly.

NestJS users

NestJS support is built into the core package — import from lombok-typescript/nestjs for LombokModule, @LogNest, @MemoizeNest, and @RetryNest. No separate install; @nestjs/common and @nestjs/core are optional peers you already have in a Nest app.

Released under the MIT License.