0

In the following code

import { useMsal } from "@azure/msal-react";

function ProfileContent() {
    const { instance, accounts } = useMsal();

    const name = accounts[0] && accounts[0].name;

JavaScript has no problem with this, and the code works as expected. But when I make this a TypeScript file, I get errors that

Property 'name' does not exist on type 'Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>

What has so drastically changed to the point that TypeScript believes the property within the library doesn't even exist?

1

1 Answer 1

1

Browsing through the source code, it looks like they might have used the wrong type in IMsalContext. There's a commit on the dev branch with the message "Fix accounts type".

Here is the current released version, the dev branch version, the pull request, and the associated issue.

Sign up to request clarification or add additional context in comments.

1 Comment

Confirmed with the dev team that this was/is a bug. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.