TypeScript中的Typeof参数对象
我基本上有这个:
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 }
所以我们有pragmatik.parse
方法:
function parse(args){ // return parsed arguments }
现在我想用TypeScript来定义types,我所知道的是参数是一个对象:
function parse(args: Object){ }
所以我的问题是:TypeScript给定义或types的JS中的arguments
对象? 对不起,这是有点meta,但请忍受我,我问的是理智的。
我的Webstorm IDEbuild议这可能是IArguments
,它是由lib/es6/d.ts
,它在那里。 也许有人可以validation这是正确的,但我相当肯定。
所以答案是:
function parse(args: IArguments){ }
完整的签名是:
function parse(args: IArguments) : Array<any> { }
因为parsing方法返回一个通用数组