Skip to content

Latest commit

 

History

History
83 lines (62 loc) · 2.04 KB

2.9_MIGRATION_GUIDE.md

File metadata and controls

83 lines (62 loc) · 2.04 KB

Migrating TypeScript project from 2.8 to 2.9

TypeScript support has been externalized in dedicated packages and have been removed from core starting Nuxt 2.9. Here are the guidelines to migrate your existing Nuxt TypeScript project to 2.9 without any trouble.

The following migration guide works for either nuxt or nuxt-edge.

1) Migrate dependencies

yarn remove @nuxt/typescript
yarn add -D @nuxt/typescript-build @nuxt/types

Use npm uninstall and npm install -D instead if you're using npm

2) Replace @nuxt/vue-app and @nuxt/config by @nuxt/types in your tsconfig.json

// tsconfig.json

"compilerOptions": {
  "types": [
     "@nuxt/types"
  ]
}

If you were importing types from @nuxt/config you need to instead import them from @nuxt/types. Types imports might have changed a little, you can get familiar with them either by triggering intellisense when importing or watch them live here now.

3) Add @nuxt/typescript-build module to your nuxt.config.js

// nuxt.config.js

export default {
  modules: ['@nuxt/typescript-build']
}

4) Move the customized options from build.typescript to module options

// nuxt.config.js

export default {
  typescript: {
    typeCheck: true,
    ignoreNotFoundWarnings: true
  }
}

You can also do it this way :

// nuxt.config.js

export default {
  modules: [
    ['@nuxt/typescript-build', {
      typeCheck: true,
      ignoreNotFoundWarnings: true
    }]
  ]
}

5) [Optional] TypeScript runtime

Install @nuxt/typescript-runtime and use nuxt-ts (or nuxts alias) command instead of nuxt/nuxt-edge to have TypeScript runtime and be able to use TypeScript in files executed at runtime such as configuration (nuxt.config.ts), modules and serverMiddlewares.

yarn add @nuxt/typescript-runtime
// package.json

"scripts": {
  "dev": "nuxt-ts",
  "build": "nuxt-ts build",
  "start": "nuxt-ts start"
  "generate": "nuxt-ts generate"
}