Set global type on Nuxt3 project
Nuxt2023-12-08 20:18 (KST)
Hi, I’m Lovefield.
Recently, I've been writing almost all projects in typescript. I think the existence of a type has a great merit, so I use it often. Nuxt3, which I mainly use, is also using typescript as a base. If you use a type, you may have to use the same type in multiple files. It's simpler than you think to use the type globally in Nuxt3.
nuxt.config.ts setting
export default defineNuxtConfig({
imports: {
dirs: ["types"],
},
});
Set the "types" folder to be imported automatically using the "imports" property. In fact, all settings have been completed with this setting. You can now simply create the "*.d.ts" file in the "types" folder and declare either interface or type. The "*.d.ts" file means that it is a file with only a declaration.
Previous Article
Using Pinia in Nuxt3
Nuxt
Next Article
[Spring Boot] Sentry default settings
Spring Boot