tsgonest vs tsgo
What tsgonest adds on top of Microsoft's typescript-go compiler.
typescript-go (tsgo) is Microsoft's official Go port of the TypeScript compiler — roughly 10x faster than tsc. tsgonest wraps tsgo and extends it with features designed for NestJS backends.
What is tsgo?
tsgo is a 1 port of the TypeScript compiler from JavaScript to Go. It produces identical output to tsc — the same JavaScript, the same type checking, the same diagnostics — just significantly faster.
tsgo is a compiler only. It compiles TypeScript to JavaScript and performs type checking. Nothing more.
What tsgonest adds
tsgonest uses tsgo as its compilation engine, then adds NestJS-specific capabilities on top:
| Feature | tsgo | tsgonest |
|---|---|---|
| TypeScript compilation | Yes | Yes (uses tsgo) |
| Type checking | Yes | Yes |
| JavaScript emit | Yes | Yes |
| Incremental builds | Yes | Yes |
| Validation codegen | No | Yes — companion files with validate/assert |
| Serialization codegen | No | Yes — fast JSON serializers |
| OpenAPI generation | No | Yes — OpenAPI 3.2 from NestJS controllers |
| Watch mode + restart | No | Yes — tsgonest dev |
| Asset copying | No | Yes — --assets flag |
| Config file | tsconfig.json only | tsconfig.json + tsgonest.config.ts |
| Post-processing cache | N/A | Yes — skips codegen when source unchanged |
When to use which
Use tsgo when
- You have a non-NestJS TypeScript project and just want faster compilation
- You don't need validation, serialization, or OpenAPI generation
- You want a drop-in replacement for
tsc - You're building a library, frontend app, or CLI tool
Use tsgonest when
- You're building a NestJS backend
- You want generated validators from your TypeScript types
- You want fast JSON serializers (~1.4x faster than JSON.stringify for simple DTOs)
- You want OpenAPI documentation without decorator overhead
- You want watch mode with automatic rebuild and restart
- You want a single tool that replaces
tsc+class-validator+class-transformer+@nestjs/swagger
# NestJS development
tsgonest dev
# Production build
tsgonest buildPerformance
Since tsgonest uses tsgo internally, compilation speed is equivalent. The additional passes add minimal overhead:
| Phase | Time (120 controllers, 838 routes) |
|---|---|
| Compilation (tsgo) | ~15s |
| Companion generation | ~3s |
| OpenAPI | ~1s |
| Total cold build | ~19s |
| Warm build (cached) | ~1.1s |
The post-processing cache means that on subsequent builds where only a few files changed, tsgonest skips companion regeneration entirely — achieving near-instant rebuilds.
Example output
tsgo output
npx @aspect-build/tsgo --project tsconfig.jsondist/
user/
user.dto.js
user.controller.js
user.module.js
main.jsJust compiled JavaScript — exactly what tsc would produce, but faster.
tsgonest output
tsgonest builddist/
user/
user.dto.js # compiled JS
user.dto.CreateUserDto.tsgonest.js # generated companion
user.dto.CreateUserDto.tsgonest.d.ts # companion types
user.dto.UserResponse.tsgonest.js # generated companion
user.dto.UserResponse.tsgonest.d.ts # companion types
user.controller.js # compiled JS
user.module.js # compiled JS
main.js
openapi.json # OpenAPI 3.2Same JavaScript output, plus companions and OpenAPI — all from a single build command.
Can I use both?
There's no need to. tsgonest includes tsgo — it's the same compilation engine. Using tsgonest gives you everything tsgo provides, plus the NestJS-specific features. If you don't configure companions or OpenAPI, tsgonest behaves identically to tsgo with watch mode added.