Skip to content

nuxtApp.hook types not recognized after v4 update #32754

@mschoeffmann

Description

@mschoeffmann

Environment

  • Operating System: Darwin
  • Node Version: v22.16.0
  • Nuxt Version: 4.0.1
  • CLI Version: 3.26.4
  • Nitro Version: 2.12.4
  • Package Manager: pnpm@10.13.1
  • Builder: -
  • User Config: app, appConfig, build, compatibilityDate, css, devtools, modules, pwa, spaLoadingTemplate, ssr, vuetify
  • Runtime Modules: @vite-pwa/nuxt@1.0.4, @nuxt/eslint@1.7.1, @nuxtjs/device@3.2.4, @vueuse/nuxt@13.5.0, vuetify-nuxt-module@0.18.7
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-bs9fzxqu-2r3h6pyx?file=app%2Fplugins%2Ficons.client.ts,app%2Fplugins%2Fpwa.client.ts

Describe the bug

After upgrading from v3 (in v4 mode since months) to v4, some types can not be resolved any more:

  • The nuxtApp.hook provided by modules

Additional context

The output of nuxt typecheck:

app/plugins/icons.client.ts:6:16 - error TS2345: Argument of type '"vuetify:configuration"' is not assignable to parameter of type 'HookKeys<RuntimeNuxtHooks>'.
6   nuxtApp.hook('vuetify:configuration', ({ vuetifyOptions }) => {
                 ~~~~~~~~~~~~~~~~~~~~~~~

app/plugins/icons.client.ts:6:44 - error TS7031: Binding element 'vuetifyOptions' implicitly has an 'any' type.
6   nuxtApp.hook('vuetify:configuration', ({ vuetifyOptions }) => {
                                             ~~~~~~~~~~~~~~

app/plugins/pwa.client.ts:2:16 - error TS2345: Argument of type '"service-worker:registered"' is not assignable to parameter of type 'HookKeys<RuntimeNuxtHooks>'.
2   nuxtApp.hook('service-worker:registered', ({ url, registration }) => {
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~

app/plugins/pwa.client.ts:2:48 - error TS7031: Binding element 'url' implicitly has an 'any' type.
2   nuxtApp.hook('service-worker:registered', ({ url, registration }) => {
                                                 ~~~

app/plugins/pwa.client.ts:2:53 - error TS7031: Binding element 'registration' implicitly has an 'any' type.
2   nuxtApp.hook('service-worker:registered', ({ url, registration }) => {
                                                      ~~~~~~~~~~~~

app/plugins/pwa.client.ts:6:16 - error TS2345: Argument of type '"service-worker:registration-failed"' is not assignable to parameter of type 'HookKeys<RuntimeNuxtHooks>'.
6   nuxtApp.hook('service-worker:registration-failed', ({ error }) => {
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

app/plugins/pwa.client.ts:6:57 - error TS7031: Binding element 'error' implicitly has an 'any' type.
6   nuxtApp.hook('service-worker:registration-failed', ({ error }) => {
                                                          ~~~~~

app/plugins/pwa.client.ts:10:16 - error TS2345: Argument of type '"service-worker:activated"' is not assignable to parameter of type 'HookKeys<RuntimeNuxtHooks>'.
10   nuxtApp.hook('service-worker:activated', ({ url, registration }) => {
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~

app/plugins/pwa.client.ts:10:47 - error TS7031: Binding element 'url' implicitly has an 'any' type.
10   nuxtApp.hook('service-worker:activated', ({ url, registration }) => {
                                                 ~~~

app/plugins/pwa.client.ts:10:52 - error TS7031: Binding element 'registration' implicitly has an 'any' type.
10   nuxtApp.hook('service-worker:activated', ({ url, registration }) => {
                                                      ~~~~~~~~~~~~

app/app.config.ts:1:62 - error TS2307: Cannot find module '~~/package.json' or its corresponding type declarations.
1 import { name, productName, version, author, homepage } from '~~/package.json'
                                                               ~~~~~~~~~~~~~~~~~


Found 11 errors.

Logs

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions