I want to add a getWeekNumber function to the Date prototype in javascript / typescript. I want to do it with an interface becease otherwise I get a error that he does not k
You can do it this way:
in DateExt.ts:
interface Date { getWeekNumber: () => number; } Date.prototype.getWeekNumber = function() { return 123;//your calculations goes here };
in your app.ts:
import './DateExt'; let a = new Date(); console.log(a.getWeekNumber());