No description
Find a file
2026-01-02 22:08:44 -08:00
.forgejo/workflows CI: Keep @lilith deps, add validation 2025-12-31 18:50:19 -08:00
.githooks chore: configure GitLab CI/CD with workspace protocol 2025-12-28 03:32:53 -08:00
.gitignore feat: configure GitLab CI/CD for npm registry publishing 2025-12-28 00:29:57 -08:00
package.json chore: bump version to 1.0.12 2026-01-02 22:08:44 -08:00
README.md docs: add comprehensive README with configuration reference 2026-01-02 20:06:19 -08:00
tsconfig.nestjs.json 🔧 migrate to @lilith namespace, remove gitlab-ci.yml 2025-12-31 01:33:12 -08:00

@lilith/typescript-config-nestjs

TypeScript configuration for NestJS applications with decorator support.

Features

  • Decorator Support: Experimental decorators enabled
  • Metadata Emission: emitDecoratorMetadata for DI
  • CommonJS Output: NestJS-compatible module format
  • Inline Source Maps: Better debugging experience
  • Extends Base: Inherits strict settings from base config

Installation

pnpm add -D @lilith/typescript-config-nestjs @lilith/typescript-config-base typescript

Usage

Create a tsconfig.json in your NestJS project:

{
  "extends": "@lilith/typescript-config-nestjs",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src",
    "baseUrl": "./",
    "paths": {
      "@/*": ["src/*"]
    }
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist", "test"]
}

Configuration

Extends Base Config

This configuration extends @lilith/typescript-config-base and adds NestJS-specific settings.

Module Settings

Option Value Description
module commonjs CommonJS modules for NestJS
moduleResolution node Node.js resolution

Decorator Support

Option Value Description
experimentalDecorators true Enable decorators
emitDecoratorMetadata true Emit design-time metadata

Source Maps

Option Value Description
inlineSourceMap true Inline source maps
inlineSources true Include sources in maps
sourceMap false Disable separate files
declarationMap false Disable declaration maps

Examples

Standard NestJS App

{
  "extends": "@lilith/typescript-config-nestjs",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src"
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"]
}

With Path Aliases

{
  "extends": "@lilith/typescript-config-nestjs",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src",
    "baseUrl": "./",
    "paths": {
      "@modules/*": ["src/modules/*"],
      "@common/*": ["src/common/*"],
      "@config/*": ["src/config/*"]
    }
  },
  "include": ["src/**/*"]
}

Monorepo Service

{
  "extends": "@lilith/typescript-config-nestjs",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src",
    "composite": true,
    "declaration": true
  },
  "include": ["src/**/*"],
  "references": [
    { "path": "../../packages/shared" }
  ]
}

With E2E Tests

{
  "extends": "@lilith/typescript-config-nestjs",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./"
  },
  "include": ["src/**/*", "test/**/*"]
}

Why These Settings?

CommonJS Modules

NestJS uses dependency injection with decorators that rely on runtime metadata. CommonJS ensures compatibility with the NestJS DI system.

Experimental Decorators

Required for NestJS decorators like @Module(), @Controller(), @Injectable(), etc.

Emit Decorator Metadata

Enables runtime type reflection for dependency injection. Without this, NestJS cannot automatically inject dependencies based on types.

Inline Source Maps

Better debugging experience in development. Source maps are embedded directly in the output files.

License

MIT