Closed dimitarbikov closed 10 months ago
Was just about to report this as well. Updated to latest luxon and have this regression as well. Both were previously valid types (strings).
This is related to #1474
I don't really understand how this was changed and not updated to a new major Semver. This completely breaks builds. Either you are now having to deal with putting try / catches everywhere (or use a library which exposes a try func for you instead) or all the typing errors that were otherwise valid before. The behavior of the respective output functions like toISO fundamentally changed to be API breaking. If you were to do the suggestion of setting to throw on invalid, behavior where it was acceptable to provide invalid values but check through the existing isValid property now completely break and behavior otherwise breaks valid type usage.
Why even bother to do versioning if not going to actually follow proper versioning?
@types/luxon
is not maintained by the Luxon maintainers. This is the wrong repository for this issue as far as I understand.
Describe the bug With the 3.2.2 types update, some properties can now return null, which breaks everything. The .toISO() function should return string, but since @types/luxon@3.2.2 it was extended to return string | null.
To Reproduce![image](https://github.com/moment/luxon/assets/99324259/d7110e16-f548-47ef-b30b-d47cad472422)
Looking at the documentation, the return type should be string: https://moment.github.io/luxon/api-docs/index.html#datetimetoiso:~:text=Returns%20an%20ISO%208601%2Dcompliant%20string%20representation%20of%20this%20DateTime
Same with zone name: https://moment.github.io/luxon/api-docs/index.html#zonename It says it should return a string, but the actual type is string or null:![image](https://github.com/moment/luxon/assets/99324259/dd8154b4-83c6-4b83-af6c-807f336e4e9d)
Actual vs Expected behavior I wouldn't expect calling ToISO() on a new DateTime object to return null. Desktop (please complete the following information):