V
V
Vann Damm2021-02-05 10:16:53
typescript
Vann Damm, 2021-02-05 10:16:53

How to type a closure?

There is a type

type changeFormStateHandlerType = (path:string)=>(elem:React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>)=>void;

I need from this type, this piece.
type CustomType = (elem:React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>)=>void;

how to pull it up from the first type, and not produce almost identical types?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex, 2021-02-05
@effect_tw

type CustomType = ReturnType<changeFormStateHandlerType>

X
xXAbraAleXx, 2021-02-05
@xXAbraAleXx

type CustomType and by analogy)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question