What is a standard way of handling typescript in Nuxt3
I'm starting a fresh project and I wonder what should I do about typescript in Nuxt 3.
Normally I would create a folder
types
and put my ordinary types there and import them in my components. But is that a "standard" approach in new Nuxt?
Since other stuff is auto imported maybe the expected way is to add this folder to auto imports?
Or maybe I should just declare types globally?
Or stick to the old way?
For example Nuxtr does not even recommend any file structure for types, so maybe there is completely different way of handling it?3 Replies
Yes, you can simply create your types in the
types
directory and import them wherever you need them.Just create your
types
folder and declare your types like this:
You don't need to import anything thanks tou auto-imports 🙂Are we obly to install
typescript
in nuxt ?