-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Migrate @woocommerce/date
to TS
#33108
Conversation
export function getChartTypeForQuery( { chartType } ) { | ||
if ( [ 'line', 'bar' ].includes( chartType ) ) { | ||
export function getChartTypeForQuery( { chartType }: Query ) { | ||
if ( chartType !== undefined && [ 'line', 'bar' ].includes( chartType ) ) { |
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.
includes
only accept string type.
Array<string>.includes(searchElement: string, fromIndex?: number | undefined): boolean
📊 Test reports for this pull request have been published and are accessible through the following links:
Latest commit referenced in the reports: Visit the WooCommerce Test Reports homepage to view all published reports. See the FAQs page if you're having problems accessing them. |
* @param {string} [option.type] Date format type, d3 or php, defaults to d3. | ||
* @return {string} Current interval. | ||
*/ | ||
export function getDateFormatsForInterval( |
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.
Moved this function here to fix no-use-before-declare
warning.
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.
This looks like quite an effort, thanks for wrangling this out, @chihsuan!
The change also was also significant, i.e: with the added null/undefined checks and error throws, so I've done a bit of testing in the analytics and dashboard to make sure none of the consumers were violating those checks. I found none, so I think we're good!
Just a nitpicky comment on test error message, but pre-approving!
packages/js/date/src/test/index.ts
Outdated
@@ -71,19 +79,25 @@ describe( 'toMoment', () => { | |||
|
|||
it( 'should handle isoFormat dates', () => { | |||
const myMoment = toMoment( 'YYYY', '2018-04-15' ); | |||
if ( myMoment === null ) fail( 'it should not reach here' ); |
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.
Nitpick but I'd prefer the fail message to be more precise, i.e: "myMoment should not be null" or something like that
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.
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! LGTM 🚢
All Submissions:
Changes proposed in this Pull Request:
Closes #33100.
This PR migrates @woocommerce/number to TS and
moment-timezone
to fix .tz() type undefined errorHow to test the changes in this Pull Request:
pnpm nx build @woocommerce/date
pnpm nx test @woocommerce/date
without errorsOther information:
pnpm nx changelog <project>
?FOR PR REVIEWER ONLY: