TrevTheDev
TrevTheDev

Reputation: 2747

Defining dynamic function parameters in Typescript

Given this:

type params = Parameters<(x: string, y:number)=>void>

In the pseudo code below how does one make fn to be (x: string, y:number)=>void, but using the params type?

type fn = (...params)=>void // type should be (x: string, y:number)=>void

Upvotes: 1

Views: 3105

Answers (1)

akuiper
akuiper

Reputation: 215117

type fn = (...p: params)=>void

should work. Type the rest parameter with type params.

Playground

Upvotes: 2

Related Questions