-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
dayjs.locale() throws type error due to type update in v.1.8.30 #964
Comments
Sorry for the inconvenience. We will fix this by adding a back |
One problem is if I added e.g.
Typescript will treat and string as valid, and IDE will have no auto-complete at all. |
That is true, and there might be better way to achieve this. But I don't imagine people are hardcoding locale strings all to often. Regardless, not having breaking changes in a patch version has a higher priority over QOL changes if it were up to me. I haven't looked at the source so I don't know what the previous behavior was, but maybe you can look into adding a warning if the locale code provided to the function is not supported, and perhaps adding the option for a fallback locale to be used in that case. |
Maybe we should roll back to |
Make it a major release and mark it a breaking change would also do it. I prefer stricter typing. |
@muuvmuuv It just comes to me that there might be user-customized locale name, like 'aaa', maybe the only thing we could do is fall back to 'string' type. |
I don't think so because you can extend the type with custom types like this: type Locale<AdditionalTypes = void> = LocalePresetType | AdditionalTypes
type CustomLocales = 'aaa' | 'bbb'
const one: Locale = 'az'
const two: Locale<CustomLocales> = 'aaa' I would fall back to |
This would be a good fix at this moment. #968 |
Folks, do we have any timeline for this to be merged and released? Any help would be highly appreciated, thank you! |
🎉 This issue has been resolved in version 1.8.31 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Describe the bug
The locale() function used to accept a string up until v1.8.30, which updated the types to use
LocalePresetType
(73813ab). This has broken our CI/CD pipelines, as our i18n implementation returns the locale code as a string.Expected behavior
Patch versions should not include type changes that are not backwards compatible with previous versions.
Information
suggestion
Add back
string
as a valid type either in the function declarations or in theLocalePresetType
union.We can work around this issue by casting the string to a
LocalePresetType
but we would prefer if we didn't have to do this everywhere our i18n interacts with dayjs.The text was updated successfully, but these errors were encountered: