N
Nuxt2w ago
Titan

[solved] Add excludes to server tsconfig

how do I modify the server/.tsconfig.json config? I'm getting this warning and I need to exclude a folder to resolve it. The root ~~/.tsconfig.json I can modify in nuxt.config.ts with:
typescript: {
strict: true,
tsConfig: {
exclude: ['../dist/**/*', '../app-native/**/*', '../wrangler/**/*', '../.husky/**/*', '../.git/**/*']
}
},
typescript: {
strict: true,
tsConfig: {
exclude: ['../dist/**/*', '../app-native/**/*', '../wrangler/**/*', '../.husky/**/*', '../.git/**/*']
}
},
But how do I modify tsConfig for the server to include the same folders? I was under the impression you can't just add exclude: to the tsconfig.json as it will overwrite the nuxt one, but let me know if that assumption is wrong.
No description
3 Replies
kapa.ai
kapa.ai2w ago
Hi @Titan. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- You're correct in your assumption that directly modifying the tsconfig.json file can overwrite the Nuxt generated one. Nuxt automatically generates a .nuxt/tsconfig.json file with the resolved aliases you are using in your Nuxt project, as well as with other sensible defaults. Overwriting options such as "compilerOptions.paths" with your own configuration will lead TypeScript to not factor in the module resolutions from ./.nuxt/tsconfig.json. This can lead to module resolutions such as #imports not being recognized (source (https://nuxt.com/docs/guide/concepts/typescript#nuxttsconfigjson)). To modify the tsconfig.server.json for the server, you can create a ~/server/tsconfig.json file and extend the Nuxt generated tsconfig.server.json file. Here's an example:
{
"extends": "../.nuxt/tsconfig.server.json"
}
{
"extends": "../.nuxt/tsconfig.server.json"
}
Currently, these values won't be respected when type checking (source (https://nuxt.com/docs/guide/directory-structure/server#server-types)). However, there's a recent pull request on the Nuxt GitHub repository that suggests a way to add exclude paths to the tsconfig.server.json file. The pull request is titled "fix(nuxt): add exclude paths to nitro tsconfig.server.json" (source (https://github.com/nuxt/nuxt/pull/22768)). You might want to keep an eye on this pull request for updates on this feature. For now, if you need to extend options provided by ./.nuxt/tsconfig.json further, you can use the alias property (https://nuxt.com/docs/api/nuxt-config#alias) within your nuxt.config. nuxi will pick them up and extend ./.nuxt/tsconfig.json accordingly. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@109997634327986176> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Titan
TitanOP2w ago
found the answer: nuxt.config.ts
nitro: {
typescript: {
tsConfig: {
exclude: ['../dist/**/*', '../app-native/**/*', '../wrangler/**/*', '../.husky/**/*', '../.git/**/*']
}
}
nitro: {
typescript: {
tsConfig: {
exclude: ['../dist/**/*', '../app-native/**/*', '../wrangler/**/*', '../.husky/**/*', '../.git/**/*']
}
}
Want results from more Discord servers?
Add your server