#VsCode (Codium) Intellisense adds inline imports when importing types inside `.vue` files
4 messages · Page 1 of 1 (latest)
The knowledge sources don't contain enough information to directly address this specific VSCode/VSCodium inline dynamic import behavior when autocompleting TypeScript types in .vue files.
However, based on what the knowledge sources do cover, here are a few things worth checking:
1. Ensure lang="ts" is set on your <script> tag
Without it, VSCode may not treat the file as TypeScript, which can cause unexpected import behavior: [TS in SFCs]
<script setup lang="ts">
// your code here
</script>
2. Use declare global for types you want globally available
If you want types recognized without any import at all, you can declare them globally in a .d.ts file: [Global type declarations]
// ~/types/my-types.d.ts
declare global {
interface IMongoCase {
test: string
}
}
export {}
3. Avoid overriding compilerOptions.paths directly in tsconfig.json
Doing so can break module resolution (e.g., #imports). Instead, extend TypeScript config via nuxt.config.ts: [Auto-generated Types]
export default defineNuxtConfig({
typescript: {
tsConfig: {
compilerOptions: {
// your overrides here
},
},
},
})
4. Try the experimental TypeScript plugin
There's an experimental Nuxt TypeScript plugin that improves TypeScript integration in VSCode: [TS plugin PR]
export default defineNuxtConfig({
experimental: {
typescriptPlugin: true,
},
})
Note: Requires
typescriptas a dependency and configuring VSCode to use the workspace TypeScript version.
For the specific inline dynamic import issue, I'd recommend checking the Nuxt GitHub issues or the Nuxt Discord, as this appears to be an editor behavior edge case not covered in the available knowledge sources.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@astral heron Kapa.ai is still learning and improving, please let me know how I did by reacting below.