Comparisons

tsgonest vs Nestia + Typia

Architecture and DX comparison between tsgonest and the Nestia/Typia ecosystem.

Nestia and Typia are TypeScript libraries by Samchon that take a similar "types as source of truth" approach to validation and serialization. This page compares tsgonest with the Nestia + Typia stack.

At a glance

FeatureNestia + Typiatsgonest
Compilationtsc with ts-patch transform plugintsgo (~10x raw compilation, ~4x full pipeline)
Validationtypia.assert<T>() callsCompile-time injection
Serializationtypia.json.stringify<T>() callsCompile-time injection
OpenAPI@nestia/swagger (runtime analysis)Static analysis at build time
NestJS integration@nestia/core custom decoratorsStandard NestJS decorators
Setupts-patch + tsconfig plugin configSingle CLI binary
Branded typestypia.tags.Format<"email"> etc.@tsgonest/types Email, Min, Max, etc.
Watch modeExternal (nodemon, ts-node-dev)Built-in tsgonest dev

Architecture difference

Typia: compiler plugin

Typia works as a TypeScript compiler plugin via ts-patch. It transforms typia.assert<T>(input) calls into inline validation code during compilation. The validation code is inlined at each call site — there is no separate companion file.

tsgonest: companion files

tsgonest analyzes your project's types and generates companion files alongside the compiled output. These are imported automatically — tsgonest's controller rewriter injects the correct import and function calls into the compiled controller JS at build time. Your source code doesn't need to reference them directly.

What this means in practice

AspectTypia (plugin)tsgonest (codegen)
Explicit calls neededYes — typia.assert<T>() at every use siteNo — injected at compile time
Bundle size impactInline code at every call siteSingle companion per type
NestJS integration@nestia/core decorators replace NestJS onesZero-config, keep standard decorators
Build toolingRequires ts-patch, plugin config in tsconfigSingle tsgonest build command
Build speedtsc speed (with plugin overhead)tsgo speed (~4x faster)

DX comparison

Defining DTOs

Both approaches let you use plain TypeScript types. The branded type syntax differs slightly:

// Typia
import typia, { tags } from 'typia';

interface CreateUserDto {
  name: string & tags.MinLength<1> & tags.MaxLength<255>;
  email: string & tags.Format<"email">;
  age: number & tags.Minimum<0> & tags.Maximum<150>;
}
// tsgonest
import { Min, Max, Email } from '@tsgonest/types';

interface CreateUserDto {
  name: string & Min<1> & Max<255>;
  email: string & Email;
  age: number & Min<0> & Max<150>;
}

tsgonest offers shorter aliases (Min vs Minimum, Email vs Format<"email">) and compound types like Range, Between, and Length.

tsgonest also recognizes typia's "typia.tag" branded type convention. If you're migrating from typia, your existing branded types will be detected automatically.

Validation

// Typia — explicit calls required
import typia from 'typia';

@Controller('users')
export class UserController {
  @Post()
  create(@Body() input: CreateUserDto) {
    const dto = typia.assert<CreateUserDto>(input); // must call explicitly
    return this.userService.create(dto);
  }
}
// tsgonest — automatic, no explicit calls needed
@Controller('users')
export class UserController {
  @Post()
  create(@Body() dto: CreateUserDto) {
    return this.userService.create(dto);
  }
}

With tsgonest, validation is injected at compile time — no pipes, no runtime setup, no explicit calls.

Nestia vs standard NestJS decorators

Nestia replaces NestJS's standard decorators with its own:

// Nestia — custom decorators
import { TypedBody, TypedRoute } from '@nestia/core';

@Controller('users')
export class UserController {
  @TypedRoute.Post()
  create(@TypedBody() dto: CreateUserDto): UserResponse {
    return this.userService.create(dto);
  }
}
// tsgonest — standard NestJS decorators
import { Controller, Post, Body } from '@nestjs/common';

@Controller('users')
export class UserController {
  @Post()
  create(@Body() dto: CreateUserDto): UserResponse {
    return this.userService.create(dto);
  }
}

tsgonest works with standard NestJS decorators — no migration to a different API.


OpenAPI generation

Nestia

Nestia generates OpenAPI at runtime — it requires booting the NestJS application and using Nestia-specific decorators.

tsgonest

tsgonest generates OpenAPI at build time via static analysis:

tsgonest.config.ts
import { defineConfig } from '@tsgonest/runtime';

export default defineConfig({
  openapi: {
    output: 'dist/openapi.json',
    title: 'My API',
    version: '1.0.0',
  },
});

No application boot. No runtime cost. Standard NestJS decorators.


Setup comparison

Typia + Nestia

npm install typia @nestia/core @nestia/sdk
npx ts-patch install
tsconfig.json
{
  "compilerOptions": {
    "plugins": [
      { "transform": "typia/lib/transform" },
      { "transform": "@nestia/core/lib/transform" }
    ]
  }
}

Requires ts-patch, plugin entries in tsconfig.json, and can conflict with other TypeScript tooling (SWC, esbuild).

tsgonest

npm install tsgonest
tsgonest.config.ts
import { defineConfig } from '@tsgonest/runtime';

export default defineConfig({
  controllers: { include: ['src/**/*.controller.ts'] },
  transforms: { validation: true, serialization: true },
  openapi: { output: 'dist/openapi.json' },
});

No patches. No plugins. No tsconfig modifications.


Feature comparison table

FeatureTypiaNestiatsgonest
Validationtypia.assert<T>()Via @TypedBody()Compile-time injection
Serializationtypia.json.stringify<T>()Via @TypedRouteCompile-time injection
OpenAPIN/A@nestia/sdk (runtime)Static analysis (build time)
Interfaces supportYesYesYes
Type aliases supportYesYesYes
Custom validatorstypia.customValidatorsVia typiaValidate<typeof fn>
Branded typestypia.tags.*Via typia tags@tsgonest/types
Transforms (trim, etc.)Not built-inNot built-inTrim, ToLowerCase, ToUpperCase
CoercionNot built-inNot built-inCoerce type tag
Default valuesNot built-inNot built-inDefault<V> type tag
Per-constraint errorsNot supportedNot supportedMin<{ value: 0, error: "..." }>
Watch modeExternal toolingExternal toolingBuilt-in tsgonest dev
Build speedtsc speedtsc speed~4x faster (tsgo)
NestJS decoratorsReplaced by NestiaCustom decoratorsStandard NestJS decorators
Multipart/form-dataN/A@TypedFormData.Body()@FormDataBody() + FormDataInterceptor
Compiler requirementts-patchts-patchNone (standalone binary)

Migration from Nestia + Typia

The fastest way to migrate is with the automated codemod:

npx tsgonest migrate --apply

This handles decorator replacement, import rewrites, dependency cleanup, and tsconfig fixes automatically. See the generated tsgonest-migrate-report.md for a summary of all changes.

For manual migration details, see the Migration from Nestia + Typia guide.

On this page