2017-03-03 65 views
4

对象基本上,我有这样的: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 

} 

现在我想用打字稿定义类型,所有我知道的是,争论是一个对象:

function parse(args: Object){ 


} 

所以我的问题是:TypeScript给定义或类型的arguments JS中的对象?对不起,这有点儿元,但请耐心等待,我问的是理智的。

回答

0

我的Webstorm IDE建议这可能是IArguments,它由:lib/es6/d.ts提供,它在某处。也许有人可以验证这是正确的,但我相当肯定。

所以答案应该是:

function parse(args: IArguments){ 


} 

和完整的签名是:

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


} 

因为parse方法返回一个通用阵列