首页 > 解决方案 > 本地机器上的打字稿错误,但不在远程测试服务器上

问题描述

我正在尝试使用 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

标签: reactjstypescript

解决方案


推荐阅读