[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:
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.3 Replies
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:
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:
----------------------<@109997634327986176> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
found the answer:
nuxt.config.ts