Getting Started
Get up and running with ts-lombok-kit in minutes.
Requirements
- TypeScript 4.8+
- Node.js 16+
- ts-patch for compiler plugin support
1. Installation
Install ts-lombok-kit and ts-patch as dev dependencies:
npm install ts-lombok-kit ts-patchOr with yarn:
yarn add ts-lombok-kit ts-patch2. Setup ts-patch
Add the prepare script to your package.json:
{
"scripts": {
"prepare": "ts-patch install -s"
}
}Then run:
npm run prepareNote: ts-patch patches the TypeScript compiler to enable custom transformers. The prepare script ensures it's set up whenever dependencies are installed.
3. Configure tsconfig.json
Add the ts-lombok-kit transformer to your tsconfig.json:
{
"compilerOptions": {
"experimentalDecorators": true,
"plugins": [
{ "transform": "ts-lombok-kit" }
]
}
}Important: Make sure experimentalDecorators is enabled.
4. Start Using Decorators
Import decorators from ts-lombok-kit/markers and use them on your classes:
1import { Data, Builder } from 'ts-lombok-kit/markers';23@Data4class User {5 id: number;6 name: string;7 email: string;8}910// All getters, setters, toString, equals, and hashCode are generated!11const user = new User(1, 'John', 'john@example.com');12console.log(user.getName()); // 'John'13console.log(user.toString()); // 'User(id=1, name=John, email=john@example.com)'IDE Support
For the best development experience, configure your IDE to use the patched TypeScript version.
VS Code
Create or update .vscode/settings.json:
{
"typescript.tsdk": "node_modules/typescript/lib"
}WebStorm / IntelliJ IDEA
Go to Settings > Languages & Frameworks > TypeScript and set the TypeScript package to node_modules/typescript.