Rest parameters in constructor functions

Topics: Language Specification
Dec 8, 2013 at 8:55 PM
Rest parameters can be used in constructor functions, but the syntax currenty is
class Foo {
    constructor (...private rest: number[]) {}
To me, the following would feel more natural, so I'd like to start a discussion on it (though there certainly is nothing "wrong" with the current behavior):
class Foo {
    constructor (private number[]) {}
Dec 9, 2013 at 6:48 PM
According to the grammar this is completely disallowed; as it stands now this is supposed to be a parse error. I don't think anyone ever thought to try the first form you wrote there (so it's surprising that it works at all!).
Dec 9, 2013 at 7:00 PM
Oh, oh well. Then I guess I shouldn't have said anything so that you guys don't "fix" it. :) To be serious though, maybe this is something that could officially be supported in the future :)