I would like to monkey patch the built in Date constructor in typescript, so when I call new Date()
, I can define what the returned date will actually be.
I have tried starting off on this question: Date constructor monkey patch but in typescript you need to provide properties for the date constructor: (Type '() => any' is missing the following properties from type 'DateConstructor': parse, UTC, now), and you can't just define properties for a simple function.
Is there a way to do this? Thanks