Repository navigation
Description
Environment
- Operating System: Linux
- Node Version: v20.9.0
- Nuxt Version: 3.13.2
- CLI Version: 3.15.0
- Nitro Version: 2.9.7
- Package Manager: [email protected]
- Builder: -
- User Config: default
- Runtime Modules: -
- Build Modules: -
Reproduction
You can add any global accessible type or interface into a defineProps generic type parameter like defineProps<GlobalType> and it will drop the exception: ERROR Pre-transform error: [@vue/compiler-sfc] Unresolvable type reference or unsupported built-in utility type.
I've created a minimal setup in a CodeSandbox where the problem is visible and reproducible:
https://codesandbox.io/p/devbox/sweet-cdn-hgtnpd
Describe the bug
I have a nuxt-module that inserts global types using addTypeTemplate. The types are generated and linked correctly in the .nuxt/nuxt.d.ts and put in the ./nuxt/types/ folder. I can include those types and interfaces everywhere I want in my IDE (VSCode) and Typescript is recognizing the new global imports.
But when I use one of this global imports, like a type or an interface as a generic type parameter in the defineProps method of a component like defineProps<MyCustomGlobalType>() I get the following exception in the browser and from the vite server:
ERROR Pre-transform error: [@vue/compiler-sfc] Unresolvable type reference or unsupported built-in utility type
/project/workspace/components/TestComponent1.vue
1 | <script setup lang="ts">
2 | defineProps<TestComponentProps>()
| ^^^^^^^^^^^^^^^^^^
3 | </script>Additional context
The funny thing is, that the global imports work if I do not use them as a root generic type parameter – it works even if I use the prop as nested props in the generic-type prop of defineProps but not as root (see TestComponent2.vue). I've made several examples in the CodeSandbox: components/TestComponent1.vue drops the exception and the other 2 components show that the rest is working fine.
It is also not related to the type-generation of my module, I have also tried generic global types of Nuxt and it drops the same error.
I have tried a lot, but wasn't able to fix it myself – any help is appreciated.
Logs
No response
Activity
danielroe commentedon Nov 2, 2024
this is likely stemming from a limitation of vue/compiler
danielroe commentedon Nov 4, 2024
Would you see if you can reproduce this in pure Vue SSR without Nuxt (reproduction sandbox), and if so, raise there? 🙏
cewald commentedon Nov 5, 2024
I'll do asap :) thanks for the hint already
lessainspasorchies commentedon Nov 17, 2024
I have the same problem with a bare Nuxt 3.14.159 app on Stackblitz.
I have a few types globally available in a global.d.ts file within
@@/types:Type check and inference works in Nitro:

None works in app.vue or components, Nuxt 3 style or with the /app folder when

future: { compatibilityVersion: 4 }is set innuxt.config.ts. (I'm hoveringaboutDatain the ContentSection component/v-for, nothing )This is the error I get:
despite having a 200 when going to
http://localhost:3000/api/aboutwith the right and whole data.The component that causes the crash:

Seems Vue is in fault here.
I reopened an old Nuxt project (in 3.12.4 with Vue 3.4.37) and everything works as it should!
lessainspasorchies commentedon Nov 23, 2024
I found a workaround by changing
with
Error is gone with the latest Vue release (3.5.13)
zulfm commentedon Aug 16, 2025
I already tried it and i works. But i don't want that pattern
i want to achieve:
not the:
Its very frustrating, help.
danielroe commentedon Aug 21, 2025
There are two pieces here. First, you need to change the format of your declaration:
declare global { - export type TestComponentProps = { + type TestComponentProps = { foo: string; bar: number; }; } export {};Having said that, I've now raised #33026 to resolve the issue,
If you need to work around it in the mean time,, you need to make sure your type template is present in the Vue global type files:
userquin commentedon Aug 21, 2025
Will check adding pwa icons types to vue, this was working with v3.* without any hack, moving .vue to .ts + defineComponent is working fine
Tenrys commentedon Sep 4, 2025
Using v4.1.0, still having this issue:
Though I just checked the reproduction, do you really need to have a module for this to work?
Prior to v4.1.0, I just had the above file, but as a normal TypeScript file, without
declare global, exporting every type, which worked just fine, if I imported them in my relevant components from#imports. However this doesn't seem to work anymore, unless I just import straight from the file my props types are defined from.Matheun commentedon Oct 28, 2025
Still having this issue in nuxt v4.2
ThomasBerneHCSE commentedon Dec 4, 2025
@danielroe Hi, it seems like we still have the issue. Without adding the type import the auto imported type shows an error. Any idea why this is still present?
7by24 commentedon Dec 18, 2025
develth commentedon Dec 18, 2025
on a fresh installed nuxt it works for me.
i just upgraded another project to latest version -> same error
btw. build and run of app works, just in dev mode
jjkuga commentedon Jul 28, 2026
I encountered the same issue with Nuxt 4.5.1. In my case, I worked around it by downgrading the TypeScript version.
Environment
4.5.1@vue/compiler-sfcconfirmed viapnpm why)Reproduction
defineProps<T>()withTimported viaimport typefrom an external file, whether using an alias or a relative path.Suspected the root cause was a TypeScript version compatibility issue
6.0.3→ works correctly7.0.2→ error occursWorkaround
Pinning TypeScript to
6.xresolves the issue:{ "dependencies": { "nuxt": "^4.5.1", "vue": "^3.5.40" }, "devDependencies": { "typescript": "^6.0.3" } }danielroe commentedon Sep 2, 2026
this was resolved in #33026 (v3.19 or v4.1)
typescript v7 does not yet work with vue - they are working on this.
if you encounter something like this again, please open a new issue 🙏