我具有以下第三方记忆功能:
declare function memoizeOne<T extends (...args: any[]) => any>(resultFn: T, isEqual?: EqualityFn): T;
export type EqualityFn = (a: any, b: any, index: number) => boolean;
我正在尝试将通用类型传递给备忘录结果函数,但到目前为止没有成功。
我尝试了以下方法:
const createMemoized = memoize( <T> (data: <T>[]): T[] => data )
const data = [ ...something of specific type ]
// Passing type like this doesnt work:
const result = createMemoized<specificType>(data)
是否可以传递类型,如果可以,如何传递?帮助将不胜感激!