Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unpack array argument directly to parameters?

I know I can do this:

function (value: [boolean, string]) {
   const [boolValue, stringValue] = value;

   // make use of boolValue and stringValue
}

But am I able to do something like this?

// doesn't work
function ([boolValue: boolean, stringValue: string]) {
   // make use of boolValue and stringValue
}
like image 542
Dave Cousineau Avatar asked Oct 13 '16 19:10

Dave Cousineau


1 Answers

Ok I figured it out, might as well post as an answer. This works:

function ([boolValue, stringValue]: [boolean, string]) {
   // make use of boolValue and stringValue
}
like image 160
Dave Cousineau Avatar answered Oct 12 '22 12:10

Dave Cousineau