Skip to content

Fix InjectionToken types to allow new inject(Token) syntax to be used with msal-angular. #7653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: msal-v5
Choose a base branch
from

Conversation

bradkovach
Copy link

(desc copied from #7484)

This PR adjusts InjectionToken instantiation to use the proper template type parameter (instead of string), so that the new Angular 14+ inject(TOKEN) syntax can be used if desired.

import { MSAL_INSTANCE, MSAL_GUARD_CONFIG, MSAL_INTERCEPTOR_CONFIG, MSAL_BROADCAST_CONFIG
@Component({
   // ...
})
export class MyComponent {
   msalInstance = inject(MSAL_INSTANCE); // resolves to IPublicClientApplication
   msalGuardConfig = inject(MSAL_GUARD_CONFIG); // resolves to MsalGuardConfiguration
   msalInterceptorConfig = inject(MSAL_INTERCEPTOR_CONFIG); // resolves to MsalInterceptorConfiguration
   msalBroadcastConfig = inject(MSAL_BROADCAST_CONFIG); // resolves to MsalBroadcastConfiguration
}

@bradkovach
Copy link
Author

@shylasummers this branch resolves all of the issues from the other PR

@shylasummers
Copy link
Contributor

Hi @bradkovach, looks like you still need to adjust the changefile. This is a major (breaking) change. Try deleting this changefile and re-running while selecting major as the type.

@shylasummers
Copy link
Contributor

@bradkovach bumping the request for a changefile fix

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Apr 14, 2025
@shylasummers
Copy link
Contributor

@bradkovach bumping one more time for the changefile fix

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Apr 22, 2025
@bradkovach
Copy link
Author

@shylasummers new beachballs are available for you

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 Awaiting response from the MSAL.js team and removed Needs: Author Feedback Awaiting response from issue author labels Apr 24, 2025
@shylasummers
Copy link
Contributor

@bradkovach Please change the changefile type to major. You also only should have one changefile.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Apr 24, 2025
@bradkovach
Copy link
Author

I sent this in as a breaking change even though it doesn't break anything because old, improper types had to be manually over-ridden, so those type casts will still be in place when folks upgrade.

Since you're targeting this for v5, I don't think that matters.

However, since there were concerns, I authored a unit test that uses @ts-expect-error to ensure that the inferred types are strong, and resistant to mistyping.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 Awaiting response from the MSAL.js team and removed Needs: Author Feedback Awaiting response from issue author labels Apr 24, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs: Attention 👋 Awaiting response from the MSAL.js team label Apr 24, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
msal-angular Related to @azure/msal-angular package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants