Installation
Forger consists of two parts: a runtime factory and a compile-time TypeScript transformer. The transformer is what makes Forger.create<T>() type-aware, so installing the package is only half of the story — the build pipeline has to apply the transformer as well.
Prerequisites
A supported TypeScript line: 5.x/6.x for Forger 2, 4.x for Forger 1 — see Versions for the full matrix.
A build that applies custom transformers:
ts-jest,ts-patch, or the Angular plugin (see Integration).
1. Install the package
Install the line matching your TypeScript generation:
Forger has no runtime dependencies, so nothing else lands in your dependency tree.
2. Install ts-patch
The transformer is applied through ts-patch, which teaches the TypeScript compiler to run transformers declared in tsconfig.json. ts-patch's major must match your TypeScript major:
3. Declare the transformer in tsconfig.json
Add the transformer to the plugins section of the compiler options:
This single entry covers all build flavors that respect plugins: ts-patch CLI builds, ts-jest with the ts-patch compiler, and the Angular integration shipped with Forger.
4. Wire up your test runner
For Jest with ts-jest, point the compiler at ts-patch and register the transformer:
Step-by-step instructions for every supported pipeline live in Integration with Jest, Integration with Angular, and Building with ts-patch.
5. Verify the setup
Create a spec and run the test suite:
If the test fails with name being undefined, the transformer is not applied — revisit step 3 and 4, and clear the Jest transform cache (jest --clearCache) after changing transformer configuration. Without the transformer, Forger.create<T>() always returns undefined (see Caveats).
Next steps
Continue with the Quick Start to forge your first object.