reactjs - 本地机器上的打字稿错误,但不在远程测试服务器上
问题描述
我正在尝试使用 Microsoft Fabric 的 UI 工具。这是我在本地机器上遇到的错误。
/Developer/React/TCV.ts/tcv/src/CategorySelection.tsx(94,9):
Type '(filterText: string, currentPersonas: IPersonaProps[], limitResults?: number | undefined) => IPersonaProps[] | Promise<IPersonaProps[]>' is not assignable to type '(filter: string, selectedItems?: IPersonaProps[] | undefined) => IPersonaProps[] | PromiseLike<IPersonaProps[]>'.
Types of parameters 'currentPersonas' and 'selectedItems' are incompatible.
Type 'IPersonaProps[] | undefined' is not assignable to type 'IPersonaProps[]'.
Type 'undefined' is not assignable to type 'IPersonaProps[]'. TS2322
92 | <CompactPeoplePicker
93 | // eslint-disable-next-line react/jsx-no-bind
> 94 | onResolveSuggestions={onFilterChanged}
| ^
95 | // eslint-disable-next-line react/jsx-no-bind
96 | onEmptyInputFocus={returnMostRecentlyUsed}
97 | getTextFromItem={getTextFromItem}
但是,当我将完全相同的代码加载到 codesandbox.io 时,错误消失了,并且工作正常。我的文件是一样的,package.json 是一样的。什么可能导致这种行为?
示例: https ://codesandbox.io/s/restless-darkness-xypss?file=/src/Search.tsx
解决方案
推荐阅读
- sql - 为什么 Oracle 不将字符转换为数字?
- mongodb - 如何减少 docker-compose 图像中的 mongo 日志详细程度?
- laravel - Laravel Eloquent "with()" 急切加载 & "whereHas()" 条件
- wpf-controls - WPF 拖放出现错误的 LongPath 问题:错误 HRESULT E_FAIL 已从对 COM 组件的调用中返回
- javascript - Joi 验证器只有一个键
- bash - 删除终端输入不会消失(BashRC?)
- typescript - 从联合类型过滤到子类型
- android - 固定旋转时的滚动位置
- bash - 将文本变量切割成4个不同变量的正确方法
- maven - 我可以更改 dir 格式的 Maven 程序集的根目录吗?