# NestJS TypeScript 7: Fix nest build and Set Up tsc 7

nest build fails on TypeScript 7. Run tsc 7 beside TypeScript 6 to keep the Nest CLI, Swagger plugin and ts-jest working with fast type checks.

By Waseem Anjum · Published 2026-11-28 · https://fabwaseem.com/blog/nestjs-typescript-7

> **TL;DR:** NestJS TypeScript 7 support is partial: tsc 7 type-checks a Nest project, but nest build and nest start fail when typescript resolves to 7.x. Alias @typescript/typescript6 as typescript for the Nest CLI, and TypeScript 7 as @typescript/native so that tsc runs 7. Building with plain tsc 7 drops CLI plugin metadata and leaves paths aliases unresolved.

NestJS TypeScript 7 support is partial today: `tsc` 7 can type-check a Nest project, but `nest build` and `nest start` stop with an error when `typescript` resolves to 7.x, because the Nest CLI needs a compiler API that TypeScript 7.0 does not ship. The setup that works is to install both: TypeScript 6 under the name `typescript` for the Nest CLI, and TypeScript 7 under an alias for fast type checks.

The commands, errors and fixes below apply to `@nestjs/cli` 12.0.15, `typescript` 7.0.2 and the `@typescript/typescript6` compatibility package.

## Does NestJS support TypeScript 7?

Not through the Nest CLI. TypeScript 7.0 is the native Go port of the compiler (previewed as `tsgo`), and its [announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/) says it does not ship with an API. The Nest CLI calls that API to read your tsconfig, compile, watch and run compiler plugins, so the open [nest-cli tracking issue](https://github.com/nestjs/nest-cli/issues/3479) lists `nest build`, `nest start` and `nest start --watch` as blocked.

| Task | `typescript@7` as `typescript` | Side-by-side setup |
| --- | --- | --- |
| `npx tsc --noEmit` | Works, runs TS 7 | Works, runs TS 7 |
| `nest build` (tsc builder) | Fails | Works, uses the TS 6 API |
| `nest build -b swc` | Fails | Works |
| `@nestjs/swagger` CLI plugin | Cannot run | Works through `nest build` |
| ts-jest | Fails | Works, uses the TS 6 API |

The framework itself is not the problem. TypeScript 7 compiles `experimentalDecorators` code and still emits the `design:paramtypes` metadata that Nest's dependency injection reads. The gap is in the tooling around the compiler.

## How do you fix "does not expose the programmatic compiler API"?

Put TypeScript 6 back under the package name `typescript`, either alone or through the side-by-side aliases in the next section. This is the error `nest build` and `nest start` print:

```text
Error  The installed TypeScript version (7.0.2) does not expose the programmatic compiler API that the Nest CLI requires. TypeScript 7.0 ships the "tsc" executable only; the compiler API is expected to return in 7.1. Please install TypeScript 6 (e.g. "npm i -D typescript@^6") until then.
```

The quickest fix is the one in the message:

```bash
npm i -D typescript@^6
```

If your project is coming from TypeScript 5, TypeScript 6 may reject your tsconfig next, so check the [tsconfig fixes](#which-tsconfig-options-break-nestjs-on-typescript-7) below.

Switching builders does not avoid the error. The CLI [checks for the API](https://github.com/nestjs/nest-cli/pull/3478) at the point where it loads `typescript`, so `-b swc`, `-b webpack` and `-b rspack` stop with the same text. CLI releases that predate the check crash with `tsBinary.getParsedCommandLineOfConfigFile is not a function` instead.

You may hit npm before you hit Nest. On a NestJS 12 project, `npm i -D typescript@^7` fails to install:

```text
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
```

The npm output names the conflicting ranges, such as `peer typescript@"^6.0.0" from @nestjs/schematics`. `@nestjs/swagger` 12 also limits its peer range to TypeScript 5.5 or 6. Forcing the install with `--legacy-peer-deps` only moves the failure to `nest build`.

## How do you set up NestJS TypeScript 7 side by side?

Alias the [`@typescript/typescript6`](https://www.npmjs.com/package/@typescript/typescript6) package to `typescript`, and alias TypeScript 7 to `@typescript/native`. Tools that import `typescript` get the 6.0 API, while the `tsc` command runs TypeScript 7. These are the aliases Microsoft documents for tools that still need the old API.

**Step 1. Install both packages** with one command:

```bash
npm i -D "@typescript/native@npm:typescript@^7.0.2" "typescript@npm:@typescript/typescript6@^6.0.2"
```

Your `package.json` now has:

```json
{
  "devDependencies": {
    "@typescript/native": "npm:typescript@^7.0.2",
    "typescript": "npm:@typescript/typescript6@^6.0.2"
  }
}
```

**Step 2. Check which compiler each command runs.** `tsc` should report a 7.x version and `tsc6` a 6.0.x version:

```bash
npx tsc -v
npx tsc6 -v
```

The package version of `@typescript/typescript6` and the compiler version it prints can differ: package 6.0.2 can report compiler 6.0.3. If `npx tsc -v` shows 6.x, delete `node_modules`, reinstall and check again.

**Step 3. Add a type-check script** that uses TypeScript 7:

```json
{
  "scripts": {
    "typecheck": "tsc -p tsconfig.json --noEmit",
    "build": "nest build",
    "start:dev": "nest start --watch"
  }
}
```

**Step 4. Run it in CI** before the build:

```bash
npm ci
npm run typecheck
npm run build
npm test
```

`npm run typecheck` is where you get the native speed. Microsoft reports that full builds are [typically between 8x and 12x faster](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/) with TypeScript 7. `nest build` still compiles with TypeScript 6, so it gets no faster, and the default builder type-checks a second time. The SWC section below removes that duplicate work.

The same aliases work on NestJS 11 with `@nestjs/cli` 11, after two preparations. First, older tooling rejects TypeScript 6 as a peer dependency, so update `ts-jest` to 29.4.7 or later and `typescript-eslint` to 8.58.0 or later if you use them. Second, the NestJS 11 starter tsconfig sets `baseUrl` and no `rootDir`, and TypeScript 6 stops `nest build` on it, so apply the tsconfig changes below. If linting broke too, the [typescript-eslint TS 7 fix](https://fabwaseem.com/blog/typescript-eslint-does-not-support-ts-7) uses this exact layout, so one change covers both.

![NestJS TypeScript 7 side-by-side setup: the typescript alias serves the TypeScript 6 API to nest build, ts-jest and plugins, while the @typescript/native alias provides tsc 7 for type checks](https://res.cloudinary.com/wasicloudinary/image/upload/v1795839758/fabwaseem/projects/d1wegmbfiqmozy67jtxz.jpg)

## Which NestJS build option should you pick?

Pick the side-by-side setup with the default builder unless build time is a real problem. It keeps every Nest CLI feature. Move to SWC when builds are slow, and compile with plain `tsc` 7 only if your app uses no CLI plugins and no `paths` aliases.

| Option | Compiler that emits JS | CLI plugins | `paths` aliases rewritten | Best for |
| --- | --- | --- | --- | --- |
| Stay on TypeScript 6 only | TS 6 | Yes | Yes | No time to change tooling |
| Side by side, default builder | TS 6 | Yes | Yes | Most projects |
| Side by side, SWC builder | SWC | With `typeCheck` on and a metadata import | Yes | Slow builds |
| Plain `tsc` 7 build | TS 7 | No | No | Small services without plugins |

## Can you build NestJS with tsc 7 and skip the Nest CLI?

Yes, if you can live without CLI features. `tsc -p tsconfig.build.json` from TypeScript 7 compiles a Nest app that boots normally, but it never runs `compilerOptions.plugins` and does not rewrite `paths` aliases. With the side-by-side packages installed, only the scripts change (add `npm i -D concurrently` for watch mode):

```json
{
  "scripts": {
    "build": "tsc -p tsconfig.build.json",
    "start:dev": "npm run build && concurrently \"tsc -p tsconfig.build.json --watch --preserveWatchOutput\" \"node --watch dist/main.js\""
  }
}
```

Use `dist/src/main.js` instead if your `rootDir` puts the output there. Check these three differences before you commit to it:

1. **Swagger metadata disappears.** With the [`@nestjs/swagger` CLI plugin](https://docs.nestjs.com/openapi/cli-plugin), `nest build` adds a static `_OPENAPI_METADATA_FACTORY()` method to your DTO classes. Plain `tsc` output has none, so the build succeeds and your OpenAPI schemas lose the properties the plugin would have described for you.
2. **Path aliases break at runtime.** `nest build` rewrites an import such as `@users/users.controller.js` into a relative path. `tsc` leaves it as written, and Node fails on startup:

   ```text
   Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@users/users.controller.js' imported from .../dist/app.module.js
   ```

3. **`nest-cli.json` is ignored.** Settings such as `assets` and `deleteOutDir` belong to the Nest CLI, so copy assets and clean `dist` in your own scripts. If you clean `dist`, also set `"incremental": false` under `compilerOptions` in `tsconfig.build.json`. With incremental builds on, the leftover `.tsbuildinfo` file makes `tsc` treat the project as up to date, so it exits successfully and writes nothing.

![NestJS build comparison on TypeScript 7: nest build keeps Swagger plugin metadata and rewrites path aliases, plain tsc 7 drops the metadata and leaves aliases that fail with ERR_MODULE_NOT_FOUND](https://res.cloudinary.com/wasicloudinary/image/upload/v1795839760/fabwaseem/projects/fvp3k1zuqz2cpthadc9q.jpg)

## How do you speed up nest build with SWC and tsc 7?

Let SWC emit the JavaScript and let `tsc` 7 do the type checking. Keep the side-by-side packages, because the Nest CLI still needs the TypeScript 6 API to start, then install the [SWC builder](https://docs.nestjs.com/recipes/swc):

```bash
npm i -D @swc/cli @swc/core
```

For an app without CLI plugins, merge these two keys into the `compilerOptions` of `nest-cli.json`:

```json
{
  "compilerOptions": {
    "builder": "swc",
    "typeCheck": false
  }
}
```

Then chain the type check in front of the build:

```json
{
  "scripts": {
    "typecheck": "tsc -p tsconfig.json --noEmit",
    "build": "npm run typecheck && nest build"
  }
}
```

SWC alone compiles files that contain type errors, so do not drop the `typecheck` step. In watch mode, run `npx tsc --noEmit --watch` in a second terminal.

### Using the Swagger plugin with SWC

Set `"typeCheck": true` and load the generated metadata yourself. With SWC the plugin does not rewrite your DTOs. Instead, the CLI type-checks with the TypeScript 6 API and writes `src/metadata.ts`, which `main.ts` has to pass to Swagger before creating the document:

```ts
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module.js';
import metadata from './metadata.js';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await SwaggerModule.loadPluginMetadata(metadata);
  const config = new DocumentBuilder().build();
  SwaggerModule.setup('api', app, () =>
    SwaggerModule.createDocument(app, config),
  );
  await app.listen(process.env.PORT ?? 3000);
}
await bootstrap();
```

With the plugin, reverse the build script so the CLI regenerates the metadata before `tsc` 7 reads it. In the other order, a missing or outdated `src/metadata.ts` fails the type check and `nest build` never runs:

```json
{
  "scripts": {
    "build": "nest build && npm run typecheck"
  }
}
```

Run `npm run build` once to create `src/metadata.ts`, then commit it. A standalone `tsc` 7 check on a fresh checkout otherwise fails with `TS2307: Cannot find module './metadata.js'`. After renaming or removing a DTO or controller, rebuild and commit the new file before CI runs `typecheck`. CommonJS projects drop the `.js` extensions and call `bootstrap()` without the top-level `await`.

SWC can also fail on circular imports. The Nest docs recommend a wrapper type such as `Relation<Profile>` for circular entity relations.

## Which tsconfig options break NestJS on TypeScript 7?

`baseUrl`, `moduleResolution: node` and settings that relied on old defaults are what break. TypeScript 6 changed the defaults for `strict`, `rootDir` and `types` and deprecated those two options; TypeScript 7 removes them. That means `nest build` on TypeScript 6 reports most of these problems too.

| Error on `tsc` 7 | Cause | Fix |
| --- | --- | --- |
| `TS5102: Option 'baseUrl' has been removed` | `baseUrl` in older Nest projects | Delete it; start `paths` targets with `./` |
| `TS5108: Option 'moduleResolution=node10' has been removed` | `"moduleResolution": "node"` | Use `nodenext` with `"module": "nodenext"` |
| `TS5011: The common source directory ... 'rootDir' setting must be explicitly set` | New `rootDir` default | Set `rootDir` |
| `TS2593: Cannot find name 'describe'` | `types` now defaults to `[]` | List `node` plus `jest` or `vitest/globals` |
| `TS2564: Property 'name' has no initializer` | `strict` is now on by default | Set `strictPropertyInitialization` to `false` for DTOs |

If your code imports paths such as `src/users/...` that only resolved through `baseUrl`, replace it with `"paths": { "*": ["./*"] }`.

`ignoreDeprecations` is not a way out. On TypeScript 6, `baseUrl` raises `TS5101` and `"ignoreDeprecations": "6.0"` silences it, but TypeScript 7 still fails with `TS5102`. TypeScript 7 also rejects `"target": "es5"`, `"esModuleInterop": false`, `downlevelIteration` and the `amd`, `umd` and `systemjs` module settings.

A `tsconfig.json` that covers all five rows looks like this. Merge these settings into your file rather than dropping the others it has:

```json
{
  "compilerOptions": {
    "module": "nodenext",
    "moduleResolution": "nodenext",
    "target": "ES2023",
    "outDir": "./dist",
    "rootDir": ".",
    "strict": true,
    "strictPropertyInitialization": false,
    "types": ["node", "jest"],
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "skipLibCheck": true
  }
}
```

Replace `jest` with `vitest/globals` if you use Vitest. `tsconfig.build.json` needs its own source root so that output stays at `dist/main.js`. The NestJS 11 starter has neither of these two settings, so add them:

```json
{
  "extends": "./tsconfig.json",
  "compilerOptions": { "rootDir": "./src" },
  "include": ["src"],
  "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}
```

For changes outside Nest, see the [TypeScript 7 upgrade guide](https://fabwaseem.com/blog/typescript-7).

## Does ts-jest work with TypeScript 7?

Only through the alias. ts-jest 29.4.15 declares a peer range of `typescript >=4.3 <7`, and when `typescript` is 7.0.2 a test suite that it transforms fails to run with this message:

```text
The TypeScript compiler "typescript" (version 7.0.2) does not expose the JavaScript compiler API required by ts-jest. To use TypeScript 7 for project type-checking, install it as "@typescript/native" and alias "@typescript/typescript6" as "typescript" for ts-jest.
```

Run the install command from step 1 and ts-jest compiles through the TypeScript 6 API again. NestJS 12 projects created by `nest new` can use Vitest instead; the [NestJS 12 migration guide](https://fabwaseem.com/blog/nestjs-12) compares Jest and Vitest on v12 and shows how to keep an existing Jest suite running.

## Will TypeScript 7.1 fix nest build?

Not by itself. TypeScript 7.1 brings a [new API](https://devblogs.microsoft.com/typescript/announcing-typescript-7-1-beta/) under entry points such as `typescript/sync`, and the Nest CLI has to be changed to use it. With `typescript@7.1.0-beta` installed, CLI 12.0.15 prints the same "does not expose the programmatic compiler API" error, including the line saying the API is expected in 7.1.

The work in progress is [nest-cli pull request 3554](https://github.com/nestjs/nest-cli/pull/3554), which is open and unmerged. As proposed:

- It adds one-shot `nest build` support for the `tsc` builder on TypeScript 7.1.
- Watch mode is left for a follow-up pull request.
- `compilerOptions.plugins` and `paths` stop the build with an error, because the new emit API accepts no custom transformers.
- SWC with `typeCheck`, webpack and Rspack still require the old API.

The [7.1 iteration plan](https://github.com/microsoft/TypeScript/issues/63703) lists the release candidate for December 1, 2026 and the stable release for a day in December that is not yet set. If your app relies on the Swagger or GraphQL plugin, plan to keep the side-by-side setup past the 7.1 release. See [TypeScript 7.1 beta features](https://fabwaseem.com/blog/typescript-7-1-beta) for the rest of that release.

## Key takeaways

- `nest build` and `nest start` fail when `typescript` is 7.x, with the SWC, webpack and Rspack builders too.
- Alias `@typescript/typescript6` as `typescript` and TypeScript 7 as `@typescript/native`; then `tsc` is 7 and the Nest CLI and ts-jest keep the 6.0 API.
- Run `tsc` 7 as a separate type-check step, and add SWC if the build itself is slow.
- Building with plain `tsc` 7 drops CLI plugin metadata and leaves `paths` aliases unresolved.
- Remove `baseUrl`, set `rootDir` and `types`, and move off `moduleResolution: node`.
- TypeScript 7.1 alone does not unblock the Nest CLI; watch the open pull request.

## Questions

### Does NestJS support TypeScript 7?

Not through the Nest CLI. tsc 7 can type-check and compile Nest code, but @nestjs/cli 12.0.15 stops nest build and nest start when the typescript package is 7.x. Install TypeScript 6 as typescript and TypeScript 7 under an alias.

### How do I fix "does not expose the programmatic compiler API" in nest build?

Make typescript resolve to the 6.0 API, either with npm i -D typescript@^6 or by aliasing it to npm:@typescript/typescript6@^6.0.2 and adding TypeScript 7 as @typescript/native.

### Can I use the SWC builder with TypeScript 7 in NestJS?

Not with TypeScript 7 installed as typescript, because the Nest CLI still stops with the same error. With the side-by-side aliases, SWC works, and you can run tsc 7 separately for type checking.

### Does the @nestjs/swagger plugin work with TypeScript 7?

It works through nest build when typescript points to the 6.0 compatibility package. A plain tsc 7 build never runs CLI plugins, so the generated OpenAPI metadata is missing.

### Is tsgo supported by the Nest CLI?

No. The Go compiler ships as TypeScript 7, and the Nest CLI has no builder for it. You can call tsc 7 yourself for type checks or for a build without plugins and path aliases.

### Will TypeScript 7.1 make nest build work?

Not on its own. The Nest CLI has to adopt the new 7.1 API; CLI 12.0.15 still rejects 7.1.0-beta, and the pull request adding support is open.
