We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The type for daysjs() does not honor the functionality described in the string + format document, after loading the CustomParseFormat plugin.
daysjs()
CustomParseFormat
The following ways of calling the daysjs() constructor are valid:
dayjs.extend(customParseFormat) dayjs('1970-01-01', 'YYYY-MM-DD') // (1) string format dayjs('1970-01-01', 'YYYY-MM-DD', true) // (2) strict parsing dayjs('1970-01-01', 'YYYY-MM-DD', 'de', true) // (3) strict parsing with locale dayjs('1970-01-01', 'YYYY-MM-DD', 'de') // (4) permissive parsing with locale
However, the typescript type file only cover cases (1) and (4), but fail to consider cases (2) and (3):
// src: https://github.com/iamkun/dayjs/blob/dev/types/index.d.ts#L4 declare function dayjs (date?: dayjs.ConfigType, option?: dayjs.OptionType, locale?: string): dayjs.Dayjs
Workarounds
A workaround for case (2) is to cast the (supposed) locale-option to any:
locale
dayjs('1970-01-01', 'YYYY-MM-DD', true as any)
Case (3) does not have a workaround, beside overwriting the types in a project-wide index.d.ts file.
The text was updated successfully, but these errors were encountered:
fix: Update type definition to support strict mode
81fe694
fix #924
Thanks. Fixed.
Sorry, something went wrong.
🎉 This issue has been resolved in version 1.8.29 🎉
The release is available on:
Your semantic-release bot 📦🚀
Successfully merging a pull request may close this issue.
The type for
daysjs()
does not honor the functionality described in the string + format document, after loading theCustomParseFormat
plugin.The following ways of calling the
daysjs()
constructor are valid:However, the typescript type file only cover cases (1) and (4), but fail to consider cases (2) and (3):
Workarounds
A workaround for case (2) is to cast the (supposed)
locale
-option to any:Case (3) does not have a workaround, beside overwriting the types in a project-wide index.d.ts file.
The text was updated successfully, but these errors were encountered: