justcodin
justcodin

Reputation: 1013

Typescript - Is there a way to make composition with functions with the same arguments?

This is my code :

type fnType = ((a: number, b: number) => void) | ((a: number, b: number) => Promise<void>);

Is there a way to avoid heavy repetition with function arguments?

Upvotes: 1

Views: 40

Answers (1)

Yes, there is


type Fn<R> = (a: number, b: number) => R;

// your type
type fnType = Fn<void> | Fn<Promise<void>>

Upvotes: 2

Related Questions