-
Notifications
You must be signed in to change notification settings - Fork 163
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
Fix minor calendar issues with TS types #676
Conversation
- change type of `era` from `unknown` to `string | undefined` - consistent ordering of `CalendarProtocol | string` - change `Calendar.from` to accept `CalendarProtocol | string` - add missing calendar param to `TimeZoneProtocol.getDateTimeFor`
Codecov Report
@@ Coverage Diff @@
## main #676 +/- ##
=======================================
Coverage 94.43% 94.43%
=======================================
Files 17 17
Lines 4760 4760
Branches 749 749
=======================================
Hits 4495 4495
Misses 262 262
Partials 3 3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this makes sense!
@@ -215,7 +215,7 @@ export namespace Temporal { | |||
year(date: Temporal.Date): number; | |||
month(date: Temporal.Date): number; | |||
day(date: Temporal.Date): number; | |||
era(date: Temporal.Date): unknown; | |||
era(date: Temporal.Date): string | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had left era
as unknown
because of #526 — there is a problem with using strings for eras that I'm not sure is surmountable; and I hadn't originally intended to check in the Japanese calendar. That said, this change is fine with me because the TS types should reflect the current polyfill, but I just wanted to make sure you were aware of #526.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I saw that & figured the design was a work in progress. I also noticed that {era: undefined}
in the current polyfill is returned in every getFields()
call, even for non-ISO calendars' Date/DateTime/etc instances. Is this the intended long-term solution, or is the goal to only add custom calendar fields to instances that have those calendars?
- tighten TS checking in the lint step by using `--strict`. - fix a few type issues that were exposed by strict mode. - add `DurationFields` and`TimeFields` types for consistency.
Found a few more TS errors in TS's strict mode, so I just pushed another commit that adds strict mode to the lint step and fixes the errors. |
- Convert protocols from TS types to TS interfaces - Export protocols (for re-use) but don't export `*Fields` types
Also, realized that if people want to build custom time zones or calendars, they'll need those protocols to be exported. And the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This PR updates TS types to fix a few minor issues with the initial calendar types:
era
fromunknown
tostring | undefined
CalendarProtocol | string
Calendar.from
to acceptCalendarProtocol | string
TimeZoneProtocol.getDateTimeFor
UPDATE:
DurationFields
andTimeFields
types for consistency with*Fields
types that include a calendar.*Fields
types