-
-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add formatDate and parseDate to typings #873
Conversation
Codecov Report
@@ Coverage Diff @@
## master #873 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 15 15
Lines 659 659
Branches 146 146
=====================================
Hits 659 659 Continue to review full report at Codecov.
|
3 similar comments
Codecov Report
@@ Coverage Diff @@
## master #873 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 15 15
Lines 659 659
Branches 146 146
=====================================
Hits 659 659 Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #873 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 15 15
Lines 659 659
Branches 146 146
=====================================
Hits 659 659 Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #873 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 15 15
Lines 659 659
Branches 146 146
=====================================
Hits 659 659 Continue to review full report at Codecov.
|
It seems that this "worked" in v7.2.4, but broke with v7.3.0 |
You declared the formatDate signature as: |
|
Is this fixed via #899? |
Current workaround for me is to simply define the functions in the project yourself, as thankfully they're relatively simple: function formatDate(date, format = 'L', locale = 'en') {
return moment(date)
.locale(locale)
.format(Array.isArray(format) ? format[0] : format);
}
function parseDate(str, format = 'L', locale = 'en') {
const m = moment(str, format, locale, true);
if (m.isValid()) {
return m.toDate();
}
return undefined;
} |
The
formatDate
andparseDate
are not mentioned in the typings for LocaleUtils although they contain them. This means the code in the example:ends up with an error in TypeScript. If this is merged, this code could be replaced by