Type hinting Vue 3 global properties from local dependency

Viewed 150

I'm currently developing a local dependency for a collection of application that will be using the same server/APIs. I have managed to successfully inject a global property into Vue using the following.

const BasePlugin = {
    install: (app: App, options: {
        domain: boolean
    }) => {
        app.config.globalProperties.$library = API
    }
  }

I am trying to provide the interface to typescript/virtual using the following code inside the dependency

declare module '@vue/runtime-core' {
  interface ComponentCustomProperties {
    $library: typeof API;
  }
}

How ever this doesn't seem to work :(

0 Answers
Related