Skip to content

[Nuxt 4] custom runtime hook type error #326

@kingyue737

Description

@kingyue737

Reproduction

https://stackblitz.com/edit/github-xblyxqpf

Description

app/plugins/vuetify.ts:2:16 - error TS2345: Argument of type '"vuetify:configuration"' is not assignable to parameter of type 'HookKeys<RuntimeNuxtHooks>'.

2   nuxtApp.hook('vuetify:configuration', () => {
                 ~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error.

Nuxt now generates separate TypeScript configurations for different contexts to provide better type-checking experiences

Ref: https://nuxt.com/docs/4.x/getting-started/upgrade#typescript-configuration-splitting

.nuxt/nuxt.node.d.ts which includes required types /// <reference types="vuetify-nuxt-module" /> is now longer included in the tsconfig for runtime code. Those types may need to be moved to something like vuetify-nuxt-module/runtime

workaround:

export default defineNuxtConfig({
  typescript: {
    tsconfig:{
      compilerOptions: {
        types: ['vuetify-nuxt-module'],
      }
    }
  },
}

Others

vuetify.config.ts also needs to be included in tsconfig.node.json. My current workaround is

// nuxt.config.ts
export default defineNuxtConfig({
  typescript: {
    nodeTsConfig: {
      include: ['../vuetify.config.ts'],
    },
  },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions