By default, Nuxt doesn't check types when you run nuxt dev or nuxt build, for performance reasons.
To enable type-checking at build or development time, install vue-tsc and typescript as development dependency:
npm install --save-dev vue-tsc typescript
yarn add --dev vue-tsc typescript
pnpm add -D vue-tsc typescript
bun add -D vue-tsc typescript
Then, run nuxt typecheck command to check your types:
npx nuxt typecheck
To enable type-checking at build or development time, you can also use the typescript.typeCheck option in your nuxt.config file:
export default defineNuxtConfig({
  typescript: {
    typeCheck: true,
  },
})
When you run nuxt dev or nuxt build, Nuxt generates the following files for IDE type support (and type checking):
.nuxt/nuxt.d.tsThis file contains the types of any modules you are using, as well as the key types that Nuxt requires. Your IDE should recognize these types automatically.
Some of the references in the file are to files that are only generated within your buildDir (.nuxt) and therefore for full typings, you will need to run nuxt dev or nuxt build.
.nuxt/tsconfig.jsonThis file contains the recommended basic TypeScript configuration for your project, including resolved aliases injected by Nuxt or modules you are using, so you can get full type support and path auto-complete for aliases like ~/file or #build/file.
imports section of nuxt.config to include directories beyond the default ones. This can be useful for auto-importing types which you're using across your app.Read more about how to extend this configuration.
./.nuxt/tsconfig.json will be overwritten by the options defined in your tsconfig.json.
Overwriting options such as "compilerOptions.paths" with your own configuration will lead TypeScript to not factor in the module resolutions from ./.nuxt/tsconfig.json. This can lead to module resolutions such as #imports not being recognized.
./.nuxt/tsconfig.json further, you can use the alias property within your nuxt.config. Nuxt will pick them up and extend ./.nuxt/tsconfig.json accordingly.Since the project is divided into multiple type contexts, it's important to augment types within the correct context to ensure they are properly recognized.
For example, if you want to augment types for the app context, the augmentation file should be placed in the app/ directory.
Similarly:
server context, place the augmentation file in the server/ directory.shared/ directory.TypeScript comes with certain checks to give you more safety and analysis of your program.
Strict checks are enabled by default in Nuxt to give you greater type safety.
If you are currently converting your codebase to TypeScript, you may want to temporarily disable strict checks by setting strict to false in your nuxt.config:
export default defineNuxtConfig({
  typescript: {
    strict: false,
  },
})