Reactjs 本地计算机上的Typescript错误,但远程测试服务器上没有
我正在尝试使用Microsoft Fabric的UI工具。这是我在本地机器上遇到的错误Reactjs 本地计算机上的Typescript错误,但远程测试服务器上没有,reactjs,typescript,Reactjs,Typescript,我正在尝试使用Microsoft Fabric的UI工具。这是我在本地机器上遇到的错误 /Developer/React/TCV.ts/tcv/src/CategorySelection.tsx(94,9): Type '(filterText: string, currentPersonas: IPersonaProps[], limitResults?: number | undefined) => IPersonaProps[] | Promise<IPersonaProps[
/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}
/Developer/React/TCV.ts/TCV/src/CategorySelection.tsx(94,9):
Type'(filterText:string,currentPersonas:IPersonaProps[],limitResults?:number |未定义)=>IPersonaProps[]| Promise'不可分配给Type'(filter:string,selectedItems?:IPersonaProps[]|未定义)=>IPersonaProps[]| PromiseLike'。
参数“currentPersonas”和“selectedItems”的类型不兼容。
类型“IPersonaProps[]|未定义”不可分配给类型“IPersonaProps[]”。
类型“undefined”不可分配给类型“IPersonaProps[]”。TS2322
92 | 94 | onResolveSuggestions={onFilterChanged}
| ^
95 |//eslint禁用下一行反应/jsx无绑定
96 | onEmptyInputFocus={returnMostRecentlyUsed}
97 | getTextFromItem={getTextFromItem}
但是,当我将完全相同的代码加载到codesandbox.io时,错误消失,工作正常。我的文件是相同的,package.json是相同的。是什么导致了这种行为
例如:
考虑到它抱怨类型“undefined”,但仅在一个环境中,我的直接猜测是,您的tsconfig启用了strictNullChecks(或其他一些严格的ish标志),但codesandbox的TSConfigTanks@user1713450中没有启用这一问题。如果您将此作为答案发布,我将接受。鉴于它抱怨类型“undefined”,但仅在一个环境中,我立即猜测您的tsconfig启用了strictNullChecks(或其他一些严格的ish标志),但codesandbox的TSConfigHanks@user1713450中没有启用,这就是问题所在。如果你将此作为答复,我将接受。