How to properly import and use the MSAL (Microsoft Authentication Library for js) into a typescript react single page application?

前端 未结 4 2020
慢半拍i
慢半拍i 2020-12-15 06:02

Problem

I can\'t seem to get the MSAL library to import properly into my typescript code. I\'m using the MSAL for JS library (which is supposed to have typings) in

4条回答
  •  天涯浪人
    2020-12-15 06:27

    As you have correctly mentioned - in the msal.d.ts there are no exports - its not a module, and therefore you should not try importing.

    Instead you can use it like this:

    /// 
    
    const userAgentApplication = new Msal.UserAgentApplication("your_client_id", null, (errorDes, token, error, tokenType) =>
        {
    
        });
    

    Note that even in readme they specify only one way of using their library - by including script tag, not by importing module. And further looking into their source code shows they are not using modules as well.

提交回复
热议问题