#How do I pass a generic type parameter to a higher order function?
7 messages · Page 1 of 1 (latest)
Preview:```ts
import {produce} from "immer"
function myGenericFunction<T extends number>(
arg1: T
) {}
interface MyState<T extends number> {
foo: T
}
const reducer = produce(
myGenericFunction,
{} as MyState
)```
You can choose specific lines to embed by selecting them before copying the link.
you'll need a name for the type parameter within the function, which in this case might go something like:
Preview:ts ... const reducer = <T extends number>() => produce(myGenericFunction<T>, {} as MyState<T>)() ...
Perfect, thank you!