NuxtN
Nuxt2w ago
15 replies
tillsanders

Where to put component types for auto-importing?

I'm converting a big component library to a Nuxt 4 layer. All components are in the
components
directory. Many use complex types that I want to auto-import in the next layer. Those types usually live in a file called
types.ts
in the folder of their component. E.g. a button component might have two paths that I want to import:
components/button/UIButton.vue
and
components/button/types.ts
. When I structure it like that, Nuxt warns me about: 'Two component files resolving to the same name Types' for all those files.

I've tried renaming them, but I'm not sure that is the best approach. I don't actually want Nuxt to detect those types as components, I just want to auto-import my types.

What is the best way to auto-import types from a Nuxt 4 Layer?
Was this page helpful?