I recently asked a question about TypeScript\'s ability to extend existing prototypes in the JavaScript API (here: Extending Object.prototype with TypeScript).
This
It is now possible since TS 1.4. See Stefan's answer above
I have this bug raised for a while now: https://typescript.codeplex.com/workitem/917
One solution that the typescript team could have (without extending the language spec) is have used interfaces for the static members and constructors : http://basarat.github.io/TypeScriptDeepDive/#/modellingstatics
Basically if lib.d.ts had:
//Pulled from lib.d.ts
interface Object {
toString(): string;
toLocaleString(): string;
valueOf(): Object;
hasOwnProperty(v: string): bool;
isPrototypeOf(v: Object): bool;
propertyIsEnumerable(v: string): bool;
[s: string]: any;
}
interface ObjectStatic {
new (value?: any): Object;
(): any;
(value: any): any;
prototype: Object;
...
}
declare var Object: ObjectStatic;
Then you could have easily added members to Object via:
interface ObjectStatic {
FooAgain(): void;
}
Object.FooAgain = function () {
// TS would be fine with this.
}
I just created a feature request for this as well : https://typescript.codeplex.com/workitem/1085