You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to make a generic function that will accept a contract, a function I want to call on this contract and its parameters. In the body I want to have some generic logic like current gas price fetching, estimateGas and error handling so I want this helper function to not have to keep rewriting this logic everywhere.
which seems like it should work but I keep getting the typescript error
Type 'T[keyof T]' does not satisfy the constraint '(...args: any) => any'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
Type 'T[string]' is not assignable to type '(...args: any) => any'.ts(2344)
Im pretty sure this should be working but TS is still yelling at me.
Ive also tried using something like
type FunctionKeys<T> = {
[K in keyof T]: T[K] extends (...args: any) => any ? K : never;
}[keyof T];
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to make a generic function that will accept a contract, a function I want to call on this contract and its parameters. In the body I want to have some generic logic like current gas price fetching, estimateGas and error handling so I want this helper function to not have to keep rewriting this logic everywhere.
I have come up with
which seems like it should work but I keep getting the typescript error
Im pretty sure this should be working but TS is still yelling at me.
Ive also tried using something like
to no success.
Anyone have any thoughts?
Beta Was this translation helpful? Give feedback.
All reactions