-
Notifications
You must be signed in to change notification settings - Fork 361
chore(clerk-js,types): Convert date properties from number to Date in CommerceSubscriptionResource #6233
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
chore(clerk-js,types): Convert date properties from number to Date in CommerceSubscriptionResource #6233
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
'@clerk/clerk-js': minor | ||
'@clerk/types': minor | ||
--- | ||
|
||
Convert date properties from number to Date in CommerceSubscriptionResource | ||
Deprecates fields of type `number` | ||
- subscription.periodStart | ||
- subscription.periodEnd | ||
- subscription.canceledAt | ||
Introduces fields of type `Date` | ||
- subscription.periodStartDate | ||
- subscription.periodEndDate | ||
- subscription.canceledAtDate | ||
- subscription.createdAt |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,7 +210,7 @@ const PlanDetailsInternal = ({ | |
{(!plan.isDefault && !isDefaultPlanImplicitlyActiveOrUpcoming) || !subscription ? ( | ||
<Drawer.Footer> | ||
{subscription ? ( | ||
subscription.canceledAt ? ( | ||
subscription.canceledAtDate ? ( | ||
<Button | ||
block | ||
textVariant='buttonLarge' | ||
|
@@ -318,7 +318,8 @@ const PlanDetailsInternal = ({ | |
? localizationKeys('commerce.cancelSubscriptionNoCharge') | ||
: localizationKeys('commerce.cancelSubscriptionAccessUntil', { | ||
plan: subscription.plan.name, | ||
date: subscription.periodEnd, | ||
// @ts-expect-error this will always be defined in this case. | ||
date: subscription.periodEndDate, | ||
Comment on lines
+321
to
+322
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify the TypeScript suppression is justified. The migration from 🏁 Script executed: #!/bin/bash
# Description: Check the type definition of periodEndDate in CommerceSubscriptionResource
# Expected: Verify if periodEndDate is optional or required in the type definition
ast-grep --pattern 'interface CommerceSubscriptionResource {
$$$
periodEndDate$_$$$
$$$
}'
# Also search for any type definitions related to subscription period dates
rg -A 3 -B 3 "periodEndDate.*[?:]" Length of output: 2751 Fix the TypeScript suppression for
Locations to update:
🤖 Prompt for AI Agents
|
||
}) | ||
} | ||
/> | ||
|
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.
💡 Verification agent
🧩 Analysis chain
Verify the unixEpochToDate utility function
The conversion logic looks correct, but ensure the
unixEpochToDate
utility function properly handles edge cases.🏁 Script executed:
Length of output: 163
I couldn’t locate
unixEpochToDate
in the initial paths—let’s do a global search to find its definition and usages.🏁 Script executed:
Length of output: 10950
Let’s inspect the implementation and its tests:
🏁 Script executed:
Length of output: 1264
Improve zero-timestamp handling in
unixEpochToDate
The current implementation
uses a falsy check (
epochInSeconds || …
), so passing0
(the Unix epoch) falls back toDate.now()
. To correctly support0
, please:packages/clerk-js/src/utils/date.ts
, update the guard:return isValidDate(date) ? date : new Date();
}
This change ensures
unixEpochToDate(0)
returns the Unix epoch rather than “now.”🤖 Prompt for AI Agents