From 33e2bd3dc0d9911066c6d73234512333ff282380 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 15 May 2023 16:36:30 +0100 Subject: [PATCH] feat(nuxt): support separate server tsconfig (#20559) --- packages/nuxt/src/core/nitro.ts | 4 +++- test/fixtures/basic/server/api/useAsyncData/count.ts | 6 ++++++ test/fixtures/basic/server/tsconfig.json | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/basic/server/tsconfig.json diff --git a/packages/nuxt/src/core/nitro.ts b/packages/nuxt/src/core/nitro.ts index 7c13f7e848..9528d734e6 100644 --- a/packages/nuxt/src/core/nitro.ts +++ b/packages/nuxt/src/core/nitro.ts @@ -92,7 +92,9 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) { layer => resolve(layer.config.srcDir, 'app.config') ), typescript: { - generateTsConfig: false + strict: true, + generateTsConfig: true, + tsconfigPath: 'tsconfig.server.json' }, publicAssets: [ nuxt.options.dev diff --git a/test/fixtures/basic/server/api/useAsyncData/count.ts b/test/fixtures/basic/server/api/useAsyncData/count.ts index 8cdb1c14aa..b529bb034c 100644 --- a/test/fixtures/basic/server/api/useAsyncData/count.ts +++ b/test/fixtures/basic/server/api/useAsyncData/count.ts @@ -1,3 +1,9 @@ let counter = 0 +const test = () => () => { + // TODO: useNuxtApp should be undefined when type-testing a nitro route + useNuxtApp() +} +test() + export default defineEventHandler(() => ({ count: counter++ })) diff --git a/test/fixtures/basic/server/tsconfig.json b/test/fixtures/basic/server/tsconfig.json new file mode 100644 index 0000000000..b9ed69c19e --- /dev/null +++ b/test/fixtures/basic/server/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "../.nuxt/tsconfig.server.json" +}