I'm trying to write a template function, that is an arrow function, and assign it to a const variable,
This is supposed to be of the form const method: MethodType<T> = <T>(...) => { ... }
But it complains when I try to type the variable method. Below is a snippet of the code:
export type KeyMethod<T> = (data: T) => any;
export interface DiffResult<T> {
additions: T[];
updates: T[];
deletes: T[];
};
export type DiffMethod<T> = (oldState: T[], newState: T[]) => DiffResult<T>;
it complains about this template
vvv
export const diffMethod: DiffMethod<T> = <T>(oldState: T[], newState: T[]) => {
return {
additions: [],
updates: [],
deletes: []
}
};
Is there any way to do this? maybe I'm failing to follow the syntax, but I haven't found a similar example for that.
const diffMethod = <T>(oldState: T[], newState: T[]) ....