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?
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.