Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Property '$snotify' does not exist #74

Open
fdeitelhoff opened this issue Jan 19, 2019 · 3 comments
Open

The Property '$snotify' does not exist #74

fdeitelhoff opened this issue Jan 19, 2019 · 3 comments

Comments

@fdeitelhoff
Copy link

I'm trying to use vue-snotify in a Vue.js TypeScript project.

At the moment, I'm importing and using it:

import Snotify from 'vue-snotify';
Vue.use(Snotify);

I'm trying to show a toast in the global Vue.config.errorHandler. But the property $snotify isn't available on the global Vue instance like:

Vue.$snotify.success(...

Are there any other ways of doing this?

@knackjason
Copy link

I've been able to do this in my router by calling Vue.prototype.$snotify.success(...).

@RomainLanz
Copy link

Hey all! 👋

You need to extends VueJs types.
You can do that by creating an index.d.ts at the root of your directory and add the following content.

import Vue from 'vue'
import { SnotifyService } from 'vue-snotify/SnotifyService'

declare module 'vue/types/vue' {
  interface Vue {
    $snotify: SnotifyService
  }
}

This code will extends the Vue interface and add $snotifyproperty with the correct type - so you can have IntelliSense.

The best would be to have this library handle this for us.
I don't know what @artemsky thinks, I can create a PR to fix this.

@qru23
Copy link

qru23 commented Jun 15, 2020

@RomainLanz 's answser was exactly what I needed - this wasn't obvious at all nor easy to find, and wasn't mentioned anywhere in the docs!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants