Skip to content

feat(kit): easier way to define global tsConfig options - #35697

Merged
danielroe merged 8 commits into
nuxt:mainfrom
chairulakmal:feat/33678-global-tsconfig
Jul 19, 2026
Merged

danielroe merged 8 commits into
nuxt:mainfrom
chairulakmal:feat/33678-global-tsconfig

Conversation

@chairulakmal

@chairulakmal chairulakmal commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Resolves #33678

📚 Description

typescript.tsConfig is now a shared baseline for all four generated tsconfigs (app, server, node, shared), not just tsconfig.app.json. New appTsConfig and serverTsConfig join the existing nodeTsConfig/sharedTsConfig for per-context overrides.

Precedence: context-specific > global tsConfig > Nuxt/Nitro defaults. Only compilerOptions propagate globally; include/exclude stay per-context, and vueCompilerOptions stays app-only.

Per the comment in #33678, typescript.serverTsConfig replaces nitro.typescript.tsConfig in Nuxt config (v5-only, no compat sync). Modules can still set nuxt.options.nitro.typescript.tsConfig programmatically.

Tests

Cover global propagation, per-context override precedence. Docs updated for the new options.

@chairulakmal
chairulakmal requested a review from danielroe as a code owner July 19, 2026 15:29
@github-actions github-actions Bot added the 5.x label Jul 19, 2026
@coderabbitai

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/kit/src/template.ts (1)

437-505: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting the shared compiler options to reduce duplication.

The fallback compilerOptions mapped from baseTsConfig are identical for both nodeTsConfig and sharedTsConfig. Extracting them into a shared variable could reduce duplication and make it easier to maintain in the future.

♻️ Proposed refactor
   const tsConfig: TSConfig = defu(nuxt.options.typescript?.appTsConfig, baseTsConfig)
+
+  const sharedFallbackCompilerOptions = {
+    /* Base options: */
+    esModuleInterop: baseTsConfig.compilerOptions?.esModuleInterop,
+    skipLibCheck: baseTsConfig.compilerOptions?.skipLibCheck,
+    target: baseTsConfig.compilerOptions?.target,
+    allowJs: baseTsConfig.compilerOptions?.allowJs,
+    allowImportingTsExtensions: baseTsConfig.compilerOptions?.allowImportingTsExtensions,
+    resolveJsonModule: baseTsConfig.compilerOptions?.resolveJsonModule,
+    moduleDetection: baseTsConfig.compilerOptions?.moduleDetection,
+    isolatedModules: baseTsConfig.compilerOptions?.isolatedModules,
+    verbatimModuleSyntax: baseTsConfig.compilerOptions?.verbatimModuleSyntax,
+    allowArbitraryExtensions: baseTsConfig.compilerOptions?.allowArbitraryExtensions,
+    /* Strictness */
+    strict: baseTsConfig.compilerOptions?.strict,
+    noUncheckedIndexedAccess: baseTsConfig.compilerOptions?.noUncheckedIndexedAccess,
+    forceConsistentCasingInFileNames: baseTsConfig.compilerOptions?.forceConsistentCasingInFileNames,
+    noImplicitOverride: baseTsConfig.compilerOptions?.noImplicitOverride,
+    /* If NOT transpiling with TypeScript: */
+    module: baseTsConfig.compilerOptions?.module,
+    noEmit: true,
+    /* remove auto-scanning for types */
+    types: [],
+    /* add paths object for filling-in later */
+    paths: {},
+    /* Possibly consider removing the following in future */
+    moduleResolution: baseTsConfig.compilerOptions?.moduleResolution,
+    useDefineForClassFields: baseTsConfig.compilerOptions?.useDefineForClassFields,
+    noImplicitThis: baseTsConfig.compilerOptions?.noImplicitThis,
+    allowSyntheticDefaultImports: baseTsConfig.compilerOptions?.allowSyntheticDefaultImports,
+  }

   // This describes the environment where we load `nuxt.config.ts` (and modules)
   const nodeTsConfig: TSConfig = defu(nuxt.options.typescript?.nodeTsConfig, { compilerOptions: globalCompilerOptions }, {
-    compilerOptions: {
-      /* Base options: */
-      esModuleInterop: baseTsConfig.compilerOptions?.esModuleInterop,
-      skipLibCheck: baseTsConfig.compilerOptions?.skipLibCheck,
-      target: baseTsConfig.compilerOptions?.target,
-      allowJs: baseTsConfig.compilerOptions?.allowJs,
-      allowImportingTsExtensions: baseTsConfig.compilerOptions?.allowImportingTsExtensions,
-      resolveJsonModule: baseTsConfig.compilerOptions?.resolveJsonModule,
-      moduleDetection: baseTsConfig.compilerOptions?.moduleDetection,
-      isolatedModules: baseTsConfig.compilerOptions?.isolatedModules,
-      verbatimModuleSyntax: baseTsConfig.compilerOptions?.verbatimModuleSyntax,
-      allowArbitraryExtensions: baseTsConfig.compilerOptions?.allowArbitraryExtensions,
-      /* Strictness */
-      strict: baseTsConfig.compilerOptions?.strict,
-      noUncheckedIndexedAccess: baseTsConfig.compilerOptions?.noUncheckedIndexedAccess,
-      forceConsistentCasingInFileNames: baseTsConfig.compilerOptions?.forceConsistentCasingInFileNames,
-      noImplicitOverride: baseTsConfig.compilerOptions?.noImplicitOverride,
-      /* If NOT transpiling with TypeScript: */
-      module: baseTsConfig.compilerOptions?.module,
-      noEmit: true,
-      /* remove auto-scanning for types */
-      types: [],
-      /* add paths object for filling-in later */
-      paths: {},
-      /* Possibly consider removing the following in future */
-      moduleResolution: baseTsConfig.compilerOptions?.moduleResolution,
-      useDefineForClassFields: baseTsConfig.compilerOptions?.useDefineForClassFields,
-      noImplicitThis: baseTsConfig.compilerOptions?.noImplicitThis,
-      allowSyntheticDefaultImports: baseTsConfig.compilerOptions?.allowSyntheticDefaultImports,
-    },
+    compilerOptions: sharedFallbackCompilerOptions,
     include: [...nodeInclude],
     exclude: [...nodeExclude],
   } satisfies TSConfig)

   // This describes the environment where we load `nuxt.config.ts` (and modules)
   const sharedTsConfig: TSConfig = defu(nuxt.options.typescript?.sharedTsConfig, { compilerOptions: globalCompilerOptions }, {
-    compilerOptions: {
-      /* Base options: */
-      esModuleInterop: baseTsConfig.compilerOptions?.esModuleInterop,
-      skipLibCheck: baseTsConfig.compilerOptions?.skipLibCheck,
-      target: baseTsConfig.compilerOptions?.target,
-      allowJs: baseTsConfig.compilerOptions?.allowJs,
-      allowImportingTsExtensions: baseTsConfig.compilerOptions?.allowImportingTsExtensions,
-      resolveJsonModule: baseTsConfig.compilerOptions?.resolveJsonModule,
-      moduleDetection: baseTsConfig.compilerOptions?.moduleDetection,
-      isolatedModules: baseTsConfig.compilerOptions?.isolatedModules,
-      verbatimModuleSyntax: baseTsConfig.compilerOptions?.verbatimModuleSyntax,
-      allowArbitraryExtensions: baseTsConfig.compilerOptions?.allowArbitraryExtensions,
-      /* Strictness */
-      strict: baseTsConfig.compilerOptions?.strict,
-      noUncheckedIndexedAccess: baseTsConfig.compilerOptions?.noUncheckedIndexedAccess,
-      forceConsistentCasingInFileNames: baseTsConfig.compilerOptions?.forceConsistentCasingInFileNames,
-      noImplicitOverride: baseTsConfig.compilerOptions?.noImplicitOverride,
-      /* If NOT transpiling with TypeScript: */
-      module: baseTsConfig.compilerOptions?.module,
-      noEmit: true,
-      /* remove auto-scanning for types */
-      types: [],
-      /* add paths object for filling-in later */
-      paths: {},
-      /* Possibly consider removing the following in future */
-      moduleResolution: baseTsConfig.compilerOptions?.moduleResolution,
-      useDefineForClassFields: baseTsConfig.compilerOptions?.useDefineForClassFields,
-      noImplicitThis: baseTsConfig.compilerOptions?.noImplicitThis,
-      allowSyntheticDefaultImports: baseTsConfig.compilerOptions?.allowSyntheticDefaultImports,
-    },
+    compilerOptions: sharedFallbackCompilerOptions,
     include: [...sharedInclude],
     exclude: [...sharedExclude],
   } satisfies TSConfig)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/kit/src/template.ts` around lines 437 - 505, Extract the duplicated
baseTsConfig-derived compiler options from the nodeTsConfig and sharedTsConfig
definitions into one shared variable, then reuse it in both defu fallback
configurations. Preserve each config’s distinct include and exclude settings
while keeping the resulting compiler options unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/kit/src/template.ts`:
- Around line 437-505: Extract the duplicated baseTsConfig-derived compiler
options from the nodeTsConfig and sharedTsConfig definitions into one shared
variable, then reuse it in both defu fallback configurations. Preserve each
config’s distinct include and exclude settings while keeping the resulting
compiler options unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 52318f13-5a17-42f5-a269-c9255f9981a0

📥 Commits

Reviewing files that changed from the base of the PR and between 92c48c8 and a696273.

📒 Files selected for processing (10)
  • docs/2.directory-structure/3.tsconfig.md
  • docs/3.guide/4.modules/5.recipes-advanced.md
  • docs/4.api/6.nuxt-config.md
  • packages/kit/src/template.ts
  • packages/kit/test/generate-types.spec.ts
  • packages/nitro-server/src/augments.ts
  • packages/nitro-server/src/index.ts
  • packages/nuxt/src/core/nuxt.ts
  • packages/nuxt/test/load-nuxt.test.ts
  • packages/schema/src/types/schema.ts

@codspeed

codspeed Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 10.38%

❌ 1 regressed benchmark
✅ 20 untouched benchmarks
⏩ 3 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ initial production build in the minimal test fixture 1.8 s 2.1 s -10.38%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing chairulakmal:feat/33678-global-tsconfig (109dda5) with main (84b5415)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@pkg-pr-new

pkg-pr-new Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@35697

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@35697

nuxt

npm i https://pkg.pr.new/nuxt@35697

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@35697

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@35697

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@35697

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@35697

commit: 109dda5

@danielroe danielroe changed the title feat(kit): apply typescript.tsConfig to all generated tsconfigs feat(kit): apply typescript.tsConfig to all generated tsconfigs Jul 19, 2026
@danielroe

Copy link
Copy Markdown
Member

sorry @cernymatej, I thought it might be safer to keep the portal in place

@danielroe
danielroe requested a review from cernymatej July 19, 2026 19:11
@danielroe danielroe changed the title feat(kit): apply typescript.tsConfig to all generated tsconfigs feat(kit): easier way to define global tsConfig options Jul 19, 2026
@danielroe
danielroe added this pull request to the merge queue Jul 19, 2026
Merged via the queue into nuxt:main with commit 6fa51c3 Jul 19, 2026
31 of 32 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 19, 2026
2 of 5 tasks
danielroe added a commit that referenced this pull request Aug 12, 2026
@github-actions github-actions Bot mentioned this pull request Aug 12, 2026
danielroe added a commit that referenced this pull request Aug 12, 2026
@github-actions github-actions Bot mentioned this pull request Aug 12, 2026
@github-actions github-actions Bot mentioned this pull request Aug 28, 2026
@github-actions github-actions Bot mentioned this pull request Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

easier way to define global tsconfig options

2 participants