TypeScript 0.9重载是可调用的

我有以下问题的例子.在TypeScript 0.9中,我似乎能够调用重载方法的最终签名:

class Test {
    method(...names: string[]) : void;
    method(names: string[]) : void {

    }
}

var x= new Test();

x.method('One', 'Two', 'Three');
x.method(['One', 'Two', 'Three']);

在TypeScript 0.8.x中,您必须指定第三个签名,因此:

class Test {
    method(...names: string[]) : void;
    method(names: string[]) : void;
    method(names: any) : void {

    }
}

var x= new Test();

x.method('One', 'Two', 'Three');
x.method(['One', 'Two', 'Three']);

不应该隐藏最终的签名吗? (因为它最有可能包含任何类型的过度泛化签名等).

最佳答案 0.8.x的行为是正确的;我们现在已经在开发分支中修复了0.9的回归.实现签名确实永远不可见.

点赞