我在类型脚本中有一个反应组件,这给我一个错误,我不确定如何解决此错误:
getWindowFactory
我遇到错误的地方:
Argument of type 'HelpGetResponse' is not assignable to parameter of type 'SetStateAction<never[]>'.
Type 'HelpGetResponse' is not assignable to type '(prevState: never[]) => never[]'.
Type 'HelpGetResponse' provides no match for the signature '(prevState: never[]): never[]'.ts(2345)
错误出现在响应中。数据
这是helpApi声明帮助获得响应的地方:
堆叠到:
helpApi.getHelpFiles().then((response) => {
if (response.status !== 200) return;
setFiles(response.data);
checkFileContent();
});
和其他带有api调用的文件
import { IdDTO } from "./IdDTO";
import { createValidator } from "./validate";
export interface HelpDTO {
text: string;
path: string;
leaf: boolean;
children: [] | null;
}
export interface HelpGetResponse {
results: number;
data: HelpDTO[];
}