Passing array as arguments in TypeScript

Solution 1:

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);
}

Solution 2:

Use Function.prototype.apply:

T.m1.apply(this, args);

Where T is the enclosing class of m1.