![](/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.