Skip to content

Conversation

justingrant
Copy link
Contributor

@justingrant justingrant commented Dec 17, 2021

The implementation of non-ISO calendars has always been a bit sloppy and confusing since I wrote it as a proof-of-concept a year ago. Now that non-ISO calendar implementations are fully typed in #109, it's easier and safer to refactor them into a more maintainable set of ES6 classes. The inheritance structure is below, with bold classes are actual ICU calendars, the non-bold ones are base classes.

  • HelperBase - shared code for all non-ISO calendars
    • HebrewHelper
    • PersianHelper
    • IndianHelper
    • GregorianBaseHelper
      • RocHelper
      • BuddhistHelper
      • GregoryHelper
      • JapaneseHelper
      • OrthodoxBaseHelper
        • EthiopicHelper
        • EthioaaHelper
        • CopticHelper
    • ChineseBaseHelper
      • ChineseHelper
      • DangiHelper
    • IslamicBaseHelper
      • IslamicHelper
      • IslamicUmalquraHelper
      • IslamicTblaHelper
      • IslamicCivilHelper
      • IslamicRgsaHelper
      • IslamicCcHelper

This PR removes a lot of extra TS type code that is not needed using classes where types for inherited methods is implicit.

This is a pretty big PR but I wasn't sure how to split it into multiple commits given that things are pretty intertwined... once I started pulling on the ES6 thread, the whole sweater came with it. 😄

@justingrant
Copy link
Contributor Author

Oops, forgot to commit before latest force-push. Reopening!

@justingrant
Copy link
Contributor Author

FYI @ptomato and @12wrigja - Reviewing this PR is a little easier if you ignore whitespace:
image

* removes unnecessary type cast
* types the `impl` object more precisely
* removes un-needed spread operator
* adds more comments
Copy link
Contributor

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big improvement!

@ptomato spotted some leftover code that wasn't needed anymore
@justingrant justingrant changed the title WIP: Refactor non-ISO calendars to use ES6 classes Refactor non-ISO calendars to use ES6 classes Jan 12, 2022
@justingrant justingrant merged commit 9db14df into js-temporal:main Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants