Skip to content

fix: improve period unit ts type #1050

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

itsramiel
Copy link

Thank you for contributing to purchases-hybrid-common. Before pressing the "Create Pull Request" button, please provide the following:

  • A description about what and why you are contributing, even if it's trivial:
    If periodUnit can be only DAY, WEEK, MONTH or YEAR as mentioned in the comment, then it is better to type it that way. Makes it easier to switch on the predefined union or perform if checks with intellisense

  • The issue number(s) or PR number(s) in the description if you are contributing in response to those:
    There is no issue number

  • If applicable, unit tests.
    Not applicable

Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

Hi @itsramiel, thank you very much for your contribution!

Looking at it, it does make a lot of sense, unfortunately this would be a breaking change in the API, so we might hold this until the next major release. Hope that's ok!

@@ -311,7 +311,7 @@ export interface PurchasesIntroPrice {
/**
* Unit for the billing period of the discount, can be DAY, WEEK, MONTH or YEAR.
*/
readonly periodUnit: string;
readonly periodUnit: "DAY" | "WEEK" | "MONTH" | "YEAR";
Copy link
Contributor

Choose a reason for hiding this comment

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

This can also be UNKNOWN in unexpected scenarios:

Suggested change
readonly periodUnit: "DAY" | "WEEK" | "MONTH" | "YEAR";
readonly periodUnit: "DAY" | "WEEK" | "MONTH" | "YEAR" | "UNKNOWN";

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.

2 participants