From b858eff539215060fa11a5ffd76fadf0a2d1f346 Mon Sep 17 00:00:00 2001 From: Johann Schopplich Date: Mon, 10 Mar 2025 07:18:08 +0100 Subject: [PATCH 1/2] feat!: increase generated `tsconfig.json` strictness --- src/core/build/types.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/core/build/types.ts b/src/core/build/types.ts index ee4cb19969..76761adbac 100644 --- a/src/core/build/types.ts +++ b/src/core/build/types.ts @@ -190,19 +190,25 @@ export async function writeTypes(nitro: Nitro) { const tsconfigDir = dirname(tsConfigPath); const tsConfig: TSConfig = defu(nitro.options.typescript.tsConfig, { compilerOptions: { - forceConsistentCasingInFileNames: true, - strict: nitro.options.typescript.strict, - noEmit: true, + /* Base options: */ + esModuleInterop: true, + allowSyntheticDefaultImports: true, + skipLibCheck: true, target: "ESNext", - module: "ESNext", - moduleResolution: - nitro.options.experimental.typescriptBundlerResolution === false - ? "Node" - : "Bundler", allowJs: true, resolveJsonModule: true, + moduleDetection: "force", + isolatedModules: true, + verbatimModuleSyntax: true, + /* Strictness */ + strict: nitro.options.typescript.strict, + noUncheckedIndexedAccess: true, + noImplicitOverride: true, + forceConsistentCasingInFileNames: true, + /* If NOT transpiling with TypeScript: */ + // TODO: consider using 'module: preserve' (requires TS 5.4+) + module: "ESNext", jsx: "preserve", - allowSyntheticDefaultImports: true, jsxFactory: "h", jsxFragmentFactory: "Fragment", paths: { From 76dc36f479c905fc233221ab1d0358ed0f0503ec Mon Sep 17 00:00:00 2001 From: Johann Schopplich Date: Mon, 10 Mar 2025 11:23:50 +0100 Subject: [PATCH 2/2] fix: update TypeScript module setting to 'Preserve' --- src/core/build/types.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/build/types.ts b/src/core/build/types.ts index 76761adbac..ad1eba814d 100644 --- a/src/core/build/types.ts +++ b/src/core/build/types.ts @@ -206,8 +206,7 @@ export async function writeTypes(nitro: Nitro) { noImplicitOverride: true, forceConsistentCasingInFileNames: true, /* If NOT transpiling with TypeScript: */ - // TODO: consider using 'module: preserve' (requires TS 5.4+) - module: "ESNext", + module: "Preserve", jsx: "preserve", jsxFactory: "h", jsxFragmentFactory: "Fragment",