nuxt-modules / device

Nuxt module for detecting device type.
MIT License
886 stars 49 forks source link

Types are missing in Nuxt3 plugin #182

Open TheDutchCoder opened 5 months ago

TheDutchCoder commented 5 months ago

I'm having issues getting types to work with this Nuxt 3 module and plugins. Whenever $device is accessed from nuxtApp, there are no types defined.

Plugins allow you to extend the $device object, but because it's missing types, the custom extensions are marked as Property 'isInAppBrowser' does not exist on type 'Device'.ts(2339)

barandras commented 2 weeks ago

Same here, solved by manually overriding the $device instance property in the types/index.d.ts

import { ComponentCustomProperties } from 'vue'
import { Device } from '@nuxtjs/device'

declare module '@vue/runtime-core' {
  interface ComponentCustomProperties {
    $device: Device
  }
}