Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nuxt): exclude nitro output dir from type checking #19532

Merged
merged 3 commits into from Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/nuxt/src/core/nitro.ts
@@ -1,5 +1,5 @@
import { existsSync, promises as fsp } from 'node:fs'
import { resolve, join } from 'pathe'
import { resolve, join, relative } from 'pathe'
import { createNitro, createDevServer, build, prepare, copyPublicAssets, writeTypes, scanHandlers, prerender } from 'nitropack'
import type { NitroConfig, Nitro } from 'nitropack'
import { logger, resolvePath } from '@nuxt/kit'
Expand Down Expand Up @@ -226,6 +226,12 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
await scanHandlers(nitro)
await writeTypes(nitro)
}
// Exclude nitro output dir from typescript
if (!opts.tsConfig.exclude) {
opts.tsConfig.exclude = []
} else {
opts.tsConfig.exclude.push(relative(nuxt.options.buildDir, resolve(nuxt.options.rootDir, nitro.options.output.dir)))
}
danielroe marked this conversation as resolved.
Show resolved Hide resolved
opts.references.push({ path: resolve(nuxt.options.buildDir, 'types/nitro.d.ts') })
})

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Expand Up @@ -5,7 +5,7 @@
"skipLibCheck": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Node",
"moduleResolution": "node",
danielroe marked this conversation as resolved.
Show resolved Hide resolved
"strict": true,
"noImplicitAny": true,
"allowJs": true,
Expand Down