passing array as parmas argument

Topics: General
Oct 10, 2012 at 11:51 AM
Edited Oct 10, 2012 at 12:08 PM

Hi

Consider this example:

 

class Test {
    Method1(arg : string[]) {
       this.Method2(1, arg);
    }
    Method2(arg1 : number, ...params: any[]) {
    }
}

This code is valid, but conversion (or lack of any) to javascript is counterintuitive. What I expected in such case to see in javascript was a call to apply method that would concat 1 and elements of arg array as arguments to Method2. Please clarify if my intuition is wrong or this is a bug.

 

PS. haw can I call apply method on methods form TS without casting it to any?

Coordinator
Oct 10, 2012 at 4:53 PM

There are a few places we codegen JS that isn't as idiomatic as we'd like and could be improved based on what we know, like your example.  I'll add this as a change request.

Coordinator
Oct 10, 2012 at 4:53 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.