![](/img/trans.png)
[英]Why does Rhino Javascript engine complain a function does not exist?
[英]Property does not exist on type: Why does TypeScript complain while JavaScript doesn't?
在下面的代碼中
import { useMsal } from "@azure/msal-react";
function ProfileContent() {
const { instance, accounts } = useMsal();
const name = accounts[0] && accounts[0].name;
JavaScript
對此沒有任何問題,代碼按預期工作。 但是當我把它變成一個TypeScript
文件時,我得到的錯誤是
類型 'Partial<Pick<AccountInfo, "homeAccountId" 上不存在屬性 'name' | "localAccountId" | “用戶名”>>
是什么發生了如此巨大的變化,以至於 TypeScript 認為圖書館內的財產甚至不存在?
瀏覽源代碼,看起來他們可能在IMsalContext
中使用了錯誤的類型。 在dev
分支上有一個提交,消息是"Fix accounts type" 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.