Since this my fifth time (or so) experiencing issues with nuxt auto-importing the wrong thing (without me or TS noticing) I wanted to disable auto imports all together. Since I struggle to do so correctly, I want to ask three questions:
What did I try?
I added the following to my nuxt config, but things are still broken:
imports: {
autoImport: false,
},
1. Duplicated imports XXX
I still get errors like Duplicated imports "createError", the one from "#app" has been ignored, although I thought I disabled auto import. Why?
2. Typescript
Disabling auto-imports does not seem to work properly in connection with TS. I have cases where my typescript errors, although I need the line to run. i.e.:
import { fromNodeMiddleware } from '#imports';
errors with Module '"#imports"' has no exported member 'fromNodeMiddleware'., but if I remove the line and try to run I get the following runtime error: [worker reload] [worker init] defineNitroPlugin is not defined
I have other cases where I typescript fails to give errors. i.e. I have to import useRuntimeConfig from #imports manually to prevent getting a useRuntimeConfig is not defined runtime error (which is expected) , but TS fails to detect the issue during build time.
3. Where to import Nuxt / Nitro utilities from?
There are some nuxt / nitro utils that I have no idea where to import from if not from #imports. i.e. useRuntimeConfig, definePageMeta, defineNitroPlugin or fromNodeMiddleware. From where do I import those?
Thanks a lot in advance 🙃