-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
Hi guys!
We ran into a strange behaviour on StackOverflow regarding the typescript compiler. We were trying to extend the Array interface, and it worked well until we exported something. I don't know what is the expected behavior when extending builtin types interfaces, sorry if I am wrong here, but as I see a seemingly unrelated export should not affect the validity of that.
The report originates from: http://stackoverflow.com/questions/36805280/how-to-add-tolist-method-into-typescript-arrayt-class/36810621?noredirect=1#comment61231653_36810621
TypeScript Version:
Whatever version was published on the Playground (https://www.typescriptlang.org/play/index.html) on 2016.04.25. (I couldn't find it out)
Code
interface Array<T> {
ToList():List<T>;
};
class List<T> {
constructor(items: T[]) {}
};
Array.prototype.ToList = function() {
return new List(this);
};
export default "anything";Expected behavior:
Should compile. The strange thing is that when I remove the export the error vanishes.
Actual behavior:
Compilation error is shown on Array.prototype.ToList =: Property 'ToList' does not exist on type 'any[]'.
Thanks