feat(vite): check types with vue-tsc (#6012)

This commit is contained in:
Daniel Roe 2022-07-20 16:15:27 +01:00 committed by GitHub
parent eff6b0c4ca
commit edbe4fe799
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -4,7 +4,7 @@ Nuxt 3 is fully typed and provides helpful shortcuts to ensure you have access t
## Type-checking ## Type-checking
By default, Nuxt doesn't check types when you run `nuxi dev` or `nuxi build`, for performance reasons. However, you can enable type-checking at build or development time with [the `typescript.typeCheck` option in your `nuxt.config` file](/api/configuration/nuxt.config#typescript), or [manually check your types with nuxi](/api/commands/typecheck). By default, Nuxt doesn't check types when you run `nuxi dev` or `nuxi build`, for performance reasons. However, you can enable type-checking at build or development time by installing `vue-tsc` and `typescript` as devDependencies and either enabling [the `typescript.typeCheck` option in your `nuxt.config` file](/api/configuration/nuxt.config#typescript) or [manually checking your types with nuxi](/api/commands/typecheck).
```bash ```bash
yarn nuxi typecheck yarn nuxi typecheck

View File

@ -13,5 +13,5 @@ Option | Default | Description
This command sets `process.env.NODE_ENV` to `production`. To override, define `NODE_ENV` in a `.env` file or as a command-line argument. This command sets `process.env.NODE_ENV` to `production`. To override, define `NODE_ENV` in a `.env` file or as a command-line argument.
::alert ::alert
You can also enable type-checking at build or development time with [the `typescript.typeCheck` option in your `nuxt.config` file](/api/configuration/nuxt.config#typescript). You can also enable type-checking at build or development time by installing `vue-tsc` and `typescript` as devDependencies and enabling [the `typescript.typeCheck` option in your `nuxt.config` file](/api/configuration/nuxt.config#typescript).
:: ::

View File

@ -90,7 +90,7 @@ export async function buildServer (ctx: ViteBuildContext) {
// Add type-checking // Add type-checking
if (ctx.nuxt.options.typescript.typeCheck === true || (ctx.nuxt.options.typescript.typeCheck === 'build' && !ctx.nuxt.options.dev)) { if (ctx.nuxt.options.typescript.typeCheck === true || (ctx.nuxt.options.typescript.typeCheck === 'build' && !ctx.nuxt.options.dev)) {
const checker = await import('vite-plugin-checker').then(r => r.default) const checker = await import('vite-plugin-checker').then(r => r.default)
serverConfig.plugins.push(checker({ typescript: true })) serverConfig.plugins.push(checker({ vueTsc: true }))
} }
await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true }) await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true })