moment / moment

Parse, validate, manipulate, and display dates in javascript.
momentjs.com
MIT License
47.95k stars 7.05k forks source link

Typescript v4 w/ moment v2.29 #5792

Open kyleknighted opened 3 years ago

kyleknighted commented 3 years ago

Describe the bug Please correct me if I am wrong, but it appears to me that these lines

https://github.com/moment/moment/blob/develop/package.json#L28-L34

will make it that no matter which Typescript you use above 3.1 that will load the 3.1 typings from https://github.com/moment/moment/tree/develop/ts3.1-typings and it will never load the fixed typings at https://github.com/moment/moment/blob/develop/moment.d.ts

I have the latest (as of this issue) Typescript v4.1.2 and the latest (as of this issue) moment v2.29.1 but when I have a snippet such as

moment({
    hours: '12',
    minutes: 30,
    seconds: '5',
});

I get typescript errors from the 3.1 typings that strings are not allowed as seen in issue https://github.com/moment/moment/issues/5295 even though this has been fixed.

I have read through the docs, but I do not see a way to use the latest typings within moment.

Any guidance is appreciated.

marwahaha commented 3 years ago

Thanks for the message. The fixed typings are for TS 1.x users. If there is a bug in the TS 3.1 typings, we can fix that. Is there another way that these typings will not work for TS 4.1.2?