#How to inherit generic from a function? F.e. from `forwaredRef()`

10 messages · Page 1 of 1 (latest)

short vine
#

...

foggy shuttleBOT
#
OnkelTem#4669

Preview:```ts
import {forwardRef} from "react"

type FR = typeof forwardRef
// ^?```

short vine
#

As you see, FR is a type which contains a type of a generic function

#

However, I cannot use it in types

#

FR is not generic itself

#

Is there a way to inherit the generic?

subtle acorn
#

You can use instantiation expressions:

type FR<T, P> = typeof forwardRef<T, P>
short vine
#

Omg, I didn't know that. Thanks!

#

However in my task it didn't help 🙂

#

Thanks @subtle acorn