npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bollo-aggrey/ts-autogen

v1.0.3

Published

Lightweight Lombok-like decorators for TypeScript

Readme

TypeScript Autogen

🚀 Lombok-style decorators for TypeScript — Generate clean, type-safe boilerplate code with zero configuration. Works with both ESM and CommonJS modules.

npm version License: MIT npm downloads

✨ Features

  • 🏗️ @Data – Generates getters, setters, toString, equals, and hashCode
  • 🔧 @Builder – Fluent builder pattern with type-safe method chaining
  • 📝 @Getter / @Setter – Fine-grained property access control
  • 🔍 @ToString / @Equals / @HashCode – Complete object utilities
  • 🏭 @AllArgsConstructor / @NoArgsConstructor / @RequiredArgsConstructor – Flexible constructor generation
  • 🔒 @Value – Immutable objects with readonly properties
  • 🚀 @With – Immutable 'wither' methods for functional updates
  • 🎯 Full TypeScript Support with IntelliSense and type inference
  • ⚡ Zero runtime overhead – Compile-time transformations only
  • 🔄 Automatic version checking to keep your decorators up-to-date

📦 Installation

# Using npm
npm install @bollo-aggrey/ts-autogen

# Using yarn
yarn add @bollo-aggrey/ts-autogen

# Using pnpm
pnpm add @bollo-aggrey/ts-autogen

💡 The package includes automatic version checking to ensure you're always using the latest features and bug fixes. You'll be notified in your console if an update is available.

🚀 Quick Start

Basic Usage

import { Data, Builder, AllArgsConstructor, Getter, Setter, autogen } from '@bollo-aggrey/ts-autogen';

// Define your class with decorators
@Data()
@Builder()
@AllArgsConstructor()
class ProductClass {
  @Getter() @Setter() name: string = '';
  @Getter() @Setter() price: number = 0;
  @Getter() @Setter() category: string = '';

  // Custom methods are preserved
  public save(): string {
    return `Saved product: ${this.name}`;
  }
}

// Create the enhanced class
export const Product = autogen(ProductClass);

// Usage
const laptop = Product.builder()
  .name('MacBook Pro')
  .price(2499.99)
  .category('Electronics')
  .build();

console.log(laptop.getName()); // "MacBook Pro"
console.log(laptop.toString()); // "ProductClass(name=MacBook Pro, price=2499.99, category=Electronics)"

// Immutable updates with @With
const updatedLaptop = laptop.withName('MacBook Pro M2');

Advanced Usage

import { Value, Builder, With, autogen } from '@bollo-aggrey/ts-autogen';

// Create an immutable value object
@Value()
@Builder()
class ImmutablePoint {
  @With() readonly x: number;
  @With() readonly y: number;
  
  // Custom methods are preserved
  distanceToOrigin(): number {
    return Math.sqrt(this.x * this.x + this.y * this.y);
  }
}

const Point = autogen(ImmutablePoint);

const point = Point.builder().x(3).y(4).build();
console.log(point.distanceToOrigin()); // 5

// Create a new instance with updated values
const movedPoint = point.withX(5).withY(12);
console.log(movedPoint.distanceToOrigin()); // 13

## 📚 Complete Decorator Reference

### `@Getter` and `@Setter`
Generate getter and setter methods for class properties.

```typescript
class User {
  @Getter() private _name: string = '';
  @Setter() private _email: string = '';
}

const user = new User();
user.setEmail('[email protected]');
console.log(user.getEmail()); // "[email protected]"

@ToString

Generates a toString() method.

@ToString()
class Point {
  x: number = 0;
  y: number = 0;
}

const point = new Point();
console.log(point.toString()); // "Point(x=0, y=0)"

@Equals and @HashCode

Generate equals() and hashCode() methods.

@Equals()
@HashCode()
class User {
  id: number = 0;
  name: string = '';
}

const user1 = new User();
user1.id = 1;
user1.name = 'Alice';

const user2 = new User();
user2.id = 1;
user2.name = 'Alice';

console.log(user1.equals(user2)); // true

@With

Generates 'wither' methods for immutable updates.

@Value()
class Config {
  @With() readonly host: string = 'localhost';
  @With() readonly port: number = 3000;
}

const config = new Config();
const updated = config
  .withHost('example.com')
  .withPort(8080);

@RequiredArgsConstructor

Generates a constructor with required properties.

@RequiredArgsConstructor()
class User {
  @Getter() private readonly id: number;
  @Getter() private readonly name: string;
  private readonly optional?: string;
}

// Only required parameters in constructor
const user = new User(1, 'Alice');

@Data()

Combines @Getter, @Setter, @ToString, and @Equals.

@Data()
class User {
  @Getter() @Setter() name: string = '';
  @Getter() @Setter() email: string = '';
}

const UserModel = autogen(User);
// → getName(), setName(), getEmail(), setEmail(), toString(), equals()

@Builder()

Generates a fluent builder.

@Builder()
class Config {
  @Getter() host: string = '';
  @Getter() port: number = 0;
}

const ConfigModel = autogen(Config);
const config = ConfigModel.builder().host('localhost').port(3000).build();

@AllArgsConstructor() / @NoArgsConstructor()

@AllArgsConstructor()
@NoArgsConstructor()
class Point {
  @Getter() x: number = 0;
  @Getter() y: number = 0;
}

const PointModel = autogen(Point);
const point1 = new PointModel(10, 20);
const point2 = new PointModel(); // no-arg

⚙️ Configuration

TypeScript Configuration

Add to your tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "target": "ES2020",
    "module": "ESNext"
  }
}

Version Checking

The package includes an automatic version checker that runs on postinstall. To disable it, set the environment variable:

export TS_AUTOGEN_SKIP_VERSION_CHECK=true

Or check for updates manually:

npx ts-autogen-check --check-updates

🎯 Why Use TypeScript Autogen?

  • Reduced Boilerplate - Generate common methods automatically
  • Type Safety - Full TypeScript support with IntelliSense
  • Familiar API - Similar to Java Lombok for easy adoption
  • Zero Runtime Overhead - All transformations happen at compile-time
  • Immutability Support - First-class support for immutable data structures
  • Framework Agnostic - Works with any TypeScript project
  • Automatic Updates - Built-in version checking to keep you up-to-date

📋 Requirements

  • Node.js 20.0+
  • TypeScript 4.5+
  • "experimentalDecorators": true in tsconfig.json
  • "emitDecoratorMetadata": true in tsconfig.json (required for some features)

🧪 Testing

npm test

🤝 Contributing

Contributions welcome! Open issues and PRs are appreciated.

📄 License

MIT License – see LICENSE

🙏 Acknowledgments

  • Inspired by Project Lombok for Java
  • Made with ❤️ for the TypeScript community