Passing array as arguments in TypeScript

I have two methods:

static m1(...args: any[]) {
    //using args as array ...
}

static m2(str: string, ...args: any[]){
    //do something
    //....

    //call to m1
    m1(args);
}

The call to m1(1,2,3) works as expect. However, the call m2("abc",1,2,3) will pass to m1([1,2,3]), not as expect: m1(1,2,3).

So, how to pass args as arguments when make call to m1 in m2?


ANSWERS:


Use Function.prototype.apply:

T.m1.apply(this, args);

Where T is the enclosing class of m1.


Actually, using the ... again when calling the method will work.

It generates the apply call for you in javascript.

static m1(...args: any[]) {
    //using args as array ...
}

static m2(str: string, ...args: any[]){
    //do something
    //....

    //call to m1

    // m1(args);
    // BECOMES
    m1(...args);
}


 MORE:


 ? How can you enable NodeJS and ExpressJs into Typescript
 ? Generic interface declaration not working as-is on typescript 0.9.5
 ? Compiled JavaScript Files Not Appearing In Visual Studio Project
 ? Is there any difference in using overloads or optional parameters in TypeScript?
 ? The property 'jqGrid' does not exist on value of type 'JQuery'
 ? Trying to convert JQuery plugin to TypeScript
 ? Cannot extend angularjs controller in typescript
 ? Angular2 routing : redirectTo a relative url
 ? Angular 2 - Check current active route "name"
 ? Manually changing the route parameters leads to inconsistent user interface