question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript support

See original GitHub issue

I’m not sure if it’s better to comment on #4, or create a new one - but I, too, am having trouble getting this to work with Typescript.

My main.ts file looks like this:

import Vue from "vue";
import msal from "vue-msal";

Vue.use(msal, {
  auth: {
    clientId: "clientid"
  {
});

new Vue({
    //...
    created() {
        if (!this.$msal.isAuthenticated()) {
            this.$msal.signIn();
        }
    }
});

I get the error message of Could not find a declaration file for module ‘vue-msal’. Type ‘npm install @types/vue-msal’ if it exists or add a new declaration (.d.ts) file containing ‘declare module ‘vue-msal’;’. I have created the file /src/vue-msal.shims.d.ts:

declare module ‘vue-msal’; Doing so resolves the first error. However, now I am receiving an error on the this.$msal line of Property ‘$msal’ does not exist on type ‘CombinedVueInstance<Vue, Data, Methods, Computed, Readonly<Record<PropNames, any>>>’. Based on a bit of Googling, the solution seems to be “Augmenting Types for Use with Plugins”

I created another shim file /src/vue.msal.shims.d.ts with the content:

import Vue from 'vue';
import msal from 'vue-msal';

declare module 'vue/type/vue'{
  interface Vue{
    $msal: msal;
  }
}

Now I have an issue where the $msal: msal; line in the shims file has an error of Cannot use namespace ‘msal’ as a type… At this point I’m lost as to what I need to put in this shim to make everything work. Do you have an pointers that might help?

Thank you.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

4reactions
blakejacommented, Feb 25, 2020

Had to do the following to get this working:

  • In tsconfig.json, add "noImplicitAny": false to compilerOptions.
  • In my project, under \src created a new file named msal.d.ts that looks like this:
import Vue from 'vue';
import { MSALBasic } from 'vue-msal/lib/src/types'

declare module 'vue/types/vue' {
  interface Vue {
    $msal: MSALBasic;
  }
}

@drovani was close, but there was typo: declare module 'vue/type/vue' should have been declare module 'vue/types/vue'.

I believe these problems could be avoided by including a type definition file in the plugin itself, see Augmenting Types for Use with Plugins as mentioned above.

0reactions
thomas-jackson-finxcommented, Sep 5, 2022

Hello, Can anyone help me with this problem?

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript: JavaScript With Syntax For Types.
TypeScript extends JavaScript by adding types to the language. TypeScript speeds up your development experience by catching errors and providing fixes ...
Read more >
TypeScript - Wikipedia
TypeScript supports definition files that can contain type information of existing JavaScript libraries, much like C++ header files can describe the ...
Read more >
TypeScript Programming with Visual Studio Code
Visual Studio Code includes TypeScript language support but does not include the TypeScript compiler, tsc . You will need to install the TypeScript...
Read more >
TypeScript | WebStorm Documentation - JetBrains
WebStorm supports developing, running, and debugging TypeScript source code. ... Learn more from Compiling TypeScript into JavaScript.
Read more >
TypeScript support in Svelte - Learn web development
First-class TypeScript support has been Svelte's most requested feature for quite some time. Thanks to the hard work of the Svelte team, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found