Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue augmented types - XYZ does not exist on type

I'm using vue class component with typescript and I need to augment the types to use a third party module.

component

export default class TestComponent extends Vue  {

   private created() {
     this.$snotify.success('test')
   }
}

shims.d.ts

import Vue from 'vue'
import { Snotify } from 'vue-snotify'

declare module 'vue/types/vue' {
    interface VueConstructor {
      $snotify: Snotify
    }
  }

"Property $snotify does not exist on type TestComponent"

Vue.$snotify exists, but this.$snotify does not even though this extends Vue

Where am I going wrong?

like image 636
Dale Avatar asked Dec 10 '25 11:12

Dale


1 Answers

Try augmenting the Vue type instead of VueConstructor:

declare module 'vue/types/vue' {
  interface Vue {
    $snotify: Snotify
  }
}
like image 195
Decade Moon Avatar answered Dec 13 '25 10:12

Decade Moon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!