Typeof argument object in TypeScript

I basically have this:

function foo(){

 // literally pass the arguments object into the pragmatik.parse method
 // the purpose of pragmatik.parse is to handle more complex variadic functions

 const [a,b,c,d,e] = pragmatik.parse(arguments);

 // now we have the correct arguments in the expected location, using array destructuring


}

therefore we have a method pragmatik.parse:

function parse(args){

   // return parsed arguments

}

now I want to use TypeScript to determine types, all I know are the arguments to Object:

function parse(args: Object){


}

so my question is: TypeScript to give a definition or type for an object argumentsin JS? Sorry, this is a little meta, but please carry me what I ask, this is reasonable.

+4
source share
1 answer

My Webstorm IDE suggests that it could be IArgumentsthat provided by: lib/es6/d.tswhich is located somewhere there. Maybe someone can verify this correctly, but I'm absolutely sure.

So the answer will be as follows:

function parse(args: IArguments){


}

and full signature:

function parse(args: IArguments) : Array<any> {


}

parse

0

Source: https://habr.com/ru/post/1671331/


All Articles