我有一個(gè)功能(反應(yīng)鉤子):function useHandles<TPreparedValues, TValues>({ onReject, makeData,}: ArgsType<TPreparedValues, TValues>) { const handleLeavePage = (formData: TValues) => onReject(makeData(formData)) return { handleLeavePage }}其中 ArgsType 是:type ArgsType<TPreparedValues, TValues> = { onReject: (TPreparedValues) => Promise<void>, makeData: TValues => TPreparedValues};然后我使用這個(gè)鉤子:const { handleLeavePage,} = useDocumentHandles<DocumentEditInputType, ValuesType>({ onReject, makeData,})如您所見(jiàn),我定義了TValues = ValuesType。當(dāng)然,flowjs 應(yīng)該從onReject輸入中猜測(cè)它。但是當(dāng)我使用handleLeavePage 時(shí),我收到一個(gè)錯(cuò)誤: TValues[1] 與ValuesType[2] 在 property 的第一個(gè)參數(shù)中不兼容 onLeavePage。我認(rèn)為flowjs不明白,TValue是通用handleLeavePage。如何解決?
Flow js 不適用泛型
眼眸繁星
2021-11-18 16:27:47