Skip to content

BUG | useMagicKeys | TypeScript error in Nuxt #5099

@davidabou

Description

@davidabou

Describe the bug

When using useMagicKeys() together with whenever() inside a Nuxt project (with auto-imports enabled), TypeScript reports an error even though the example comes directly from the VueUse documentation:

const keys = useMagicKeys()

whenever(keys.shift_space, () => {
  console.log('Shift+Space have been pressed')
})

Error message:

Argument of type 'ComputedRef<boolean> | undefined' is not assignable to parameter of type 'WatchSource<boolean | null | undefined>'.
  Type 'undefined' is not assignable to type 'WatchSource<boolean | null | undefined>'.ts(2345)

Expected behavior

This should not have any TypeScript error, as it matches the example shown in the official VueUse documentation for useMagicKeys.

Reproduction

https://stackblitz.com/edit/nuxt-starter-7qqmncwa?file=app%2Fapp.vue

System Info

- Operating System: `Windows_NT`
- Node Version:     `v22.19.0`
- Nuxt Version:     `4.1.2`
- CLI Version:      `3.28.0`
- Nitro Version:    `2.12.6`
- Package Manager:  `pnpm@10.18.2`
- Builder:          `-`
- User Config:      `compatibilityDate`, `devtools`, `css`, `vite`, `modules`, `fonts`, `icon`
- Runtime Modules:  `@nuxt/fonts@0.11.4`, `@nuxt/icon@2.0.0`, `@nuxt/image@1.11.0`, `@vueuse/nuxt@13.9.0`, `reka-ui/nuxt@2.5.1`
- Build Modules:    `-`

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions