Fenton
Fenton

Reputation: 251162

TypeScript 0.9 Overload Is Callable

I have the following example of the issue. In TypeScript 0.9 I seem to be able to call the final signature of an overloaded method:

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

    }
}

var x= new Test();

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

In TypeScript 0.8.x you would have to specify a third signature, thus:

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']);

Shouldn't the final signature be hidden? (Because it is most likely to contain an over-generalised signature with any types etc).

Upvotes: 4

Views: 118

Answers (1)

Ryan Cavanaugh
Ryan Cavanaugh

Reputation: 221262

The 0.8.x behavior is correct; we had a regression in 0.9 that's fixed in the develop branch now. Implementation signatures are indeed never visible.

Upvotes: 2

Related Questions