mvertopoulos / vue-msal

Vue plugin for using Microsoft Authentication Library (MSAL)
MIT License
123 stars 66 forks source link

Typscript declaration file for module missing #19

Open blugri opened 4 years ago

blugri commented 4 years ago

Vue.js run error:

Could not find a declaration file for module 'vue-msal'. Try npm install @types/vue-msal if it exists or add a new declaration (.d.ts) file containing declare module 'vue-msal';

when running the npm command the following error is displayed.

npm install @types/vue-msal npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2fvue-msal - Not found npm ERR! 404 npm ERR! 404 '@types/vue-msal@latest' is not in the npm registry. npm ERR! 404 You should bug the author to publish it (or use the name yourself!) npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url.

ddlaat commented 4 years ago

Just add a file to your root with for example the name vue-msal.d.ts and add the following line:

declare module 'vue-msal';

grobgl commented 4 years ago

For reference, this is what I had to do:

// types/vue-msal/index.d.ts

declare module 'vue-msal' {
  import _Vue from 'vue';
  import { DataObject, Options } from 'vue-msal/lib/src/types';

  export class msalMixin extends Vue {
    readonly msal: DataObject
  }

  export default function MsalPlugin<Options>(Vue: typeof _Vue, options: Options): void
}
// types/vue/index.ts

import VueRouter, { Route } from 'vue-router';
import { MSALBasic } from 'vue-msal/lib/src/types';

declare module 'vue/types/vue' {
  interface Vue {
    $router: VueRouter
    $route: Route
    $msal: MSALBasic
  }
}