Extending an interface in TypeScript

Viewed 13726

In JavaScript, it is straight-forwardd to add functions and members to the prototype of any type. I'm trying to achieve the same in TypeScript as follows:

interface Date
{
    Minimum: Date;
}

Date.prototype.Minimum = function () { return (new Date()); }

This produces the following error:

Type '() => Date' is not assignable to type 'Date'.
Property 'toDateString' is missing in type '() => Date'.

Considering TS is strongly-types, how could we achieve this?

Since I'm writing a custom utility library in TS, I'd rather not resort to JS.

2 Answers
Related