microsoft-authentication-library-for-js: PublicClientApplication type mismatches
Core Library
MSAL.js v2 (@azure/msal-browser)
Core Library Version
2.37.0
Wrapper Library
MSAL Angular (@azure/msal-angular)
Wrapper Library Version
2.5.7
Public or Confidential Client?
Public
Description
After upgrading to the above npm version I’m now getting errors about incompatible PublicClientApplication types.
Error Message
Error: src/app/provide-azure.ts:36:55 - error TS2322: Type ‘import(“C:/Users/grosch/source/repos/newlamp/web/node_modules/@azure/msal-browser/dist/app/PublicCli entApplication”).PublicClientApplication’ is not assignable to type ‘import(“C:/Users/grosch/source/repos/newlamp/web/node_modules/@microsoft/mgt-msal2-provider /node_modules/@azure/msal-browser/dist/app/PublicClientApplication”).PublicClientApplication’. Types have separate declarations of a private property ‘activeSilentTokenRequests’.
36 Providers.globalProvider = new Msal2Provider({publicClientApplication}) ~~~~~~~~~~~~~~~~~~~~~~~
Error: src/app/provide-azure.ts:55:55 - error TS2322: Type ‘import(“C:/Users/grosch/source/repos/newlamp/web/node_modules/@azure/msal-browser/dist/app/PublicCli entApplication”).PublicClientApplication’ is not assignable to type ‘import(“C:/Users/grosch/source/repos/newlamp/web/node_modules/@microsoft/mgt-msal2-provider /node_modules/@azure/msal-browser/dist/app/PublicClientApplication”).PublicClientApplication’.
55 Providers.globalProvider = new Msal2Provider({publicClientApplication}) ~~~~~~~~~~~~~~~~~~~~~~~
Msal Logs
No response
MSAL Configuration
{
auth: {
clientId: environment.azure.clientId,
authority: 'https://login.microsoftonline.com/...',
redirectUri: window.location.origin
},
cache: {
cacheLocation: BrowserCacheLocation.LocalStorage,
storeAuthStateInCookie: false
}
}
Relevant Code Snippets
const publicClientApplication = new PublicClientApplication({
auth: {
clientId: environment.azure.clientId,
authority: 'https://login.microsoftonline.com/...',
redirectUri: window.location.origin
},
cache: {
cacheLocation: BrowserCacheLocation.LocalStorage,
storeAuthStateInCookie: false
}
})
export const provideAzure = () => makeEnvironmentProviders([{
provide: APP_INITIALIZER,
useFactory: (msalService: MsalService) => async () => {
Providers.globalProvider = new Msal2Provider({publicClientApplication})
Reproduction Steps
Just trying to compile the code.
Expected Behavior
Not a compiler error.
Identity Provider
Azure AD / MSA
Browsers Affected (Select all that apply)
Chrome
Regression
Not sure which version it was on previously.
Source
External (Customer)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15
This issue is still happening and can be easily reproduced, why is it closed if the problem still hasn’t been resolved?
This code is sufficient to see the type mismatch:
It is currently happening for
@IMBeniamin Yes, these libraries are incredibly painful to work with, and cause issues every time I want to upgrade something. I tried going to version 4 like you and and it didn’t work at all, so I went back, but essentially what you have to do is add this to your package.json:
That way, whether someone uses yarn or npm, it’ll force those versions in the other packages that try to reference them and you won’t get the errors.