Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Replace propTypes with TypeScript definitions #9673

Closed
wants to merge 1 commit into from
Closed

Replace propTypes with TypeScript definitions #9673

wants to merge 1 commit into from

Conversation

Sadaf-A
Copy link

@Sadaf-A Sadaf-A commented Jun 1, 2023

Fixes #9546

This PR replaces propTypes with TypeScript definitions in block.tsx

Testing

Automated Tests

  • Changes in this PR are covered by Automated Tests.
    • Unit tests
    • E2E tests

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Changelog

#9546 Replace propTypes with TypeScript definitions

@Sadaf-A Sadaf-A marked this pull request as ready for review June 1, 2023 06:20
@Sadaf-A Sadaf-A changed the title #9546 Replace propTypes with TypeScript definitions Replace propTypes with TypeScript definitions #9546 Jun 1, 2023
@nielslange nielslange self-requested a review June 1, 2023 06:43
@nielslange nielslange changed the title Replace propTypes with TypeScript definitions #9546 Replace propTypes with TypeScript definitions Jun 1, 2023
@nielslange nielslange mentioned this pull request Jun 1, 2023
@nielslange nielslange added type: refactor The issue/PR is related to refactoring. skip-changelog PRs that you don't want to appear in the changelog. block: active filters Issues related to the Active Filters block. labels Jun 1, 2023
Copy link
Member

@nielslange nielslange left a comment

Choose a reason for hiding this comment

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

Thank you so much for your contribution, @Sadaf-A. We really appreciate you working on this. 🙌

I briefly reviewed the PR and noticed that your PR changed the package-lock.json file. This PR should not affect this file. Would you mind double-checking this respectively excluding that file? Usually, that file changes when dependencies are updated, which is not the case in this PR.

Apart from that, I also add a few suggestions below. If you require any further assistance, please don't hesitate to reach out. 😀

@@ -413,15 +412,18 @@ const ActiveFiltersBlock = ( {
);
};

ActiveFiltersBlock.propTypes = {
interface ActiveFiltersBlock {
Copy link
Member

Choose a reason for hiding this comment

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

I'm afraid, this will not work. The component itself is already called ActiveFiltersBlock. Having an interface with the same name, leads to a naming conflict. In other PRs, we usually use the name of the component and add Props to the end. In this case, given that the component is called ActiveFiltersBlock, the interface with the TS definitions would be named ActiveFiltersBlockProps. You can find examples of that on https://github.com/hritikchaudhary/woocommerce-blocks/blob/923f89ef0a2050438d84fd2b4097f8c84d1e0ad5/assets/js/blocks/product-new/block.tsx#L22-L26

Comment on lines +419 to +422
attributes: {
// Define the properties of the attributes object.
// Adjust the types accordingly.
};
Copy link
Member

Choose a reason for hiding this comment

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

/**
* Whether it's in the editor or frontend display.
*/
isEditor: PropTypes.bool,
};
isEditor?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Similar to my previous suggestion, I think it's better if we use the type definitions from https://github.com/woocommerce/woocommerce-blocks/blob/trunk/assets/js/blocks/active-filters/types.ts. As these type definitions don't have the definition isEditor?: boolean; yet, should should add it there.

@Sadaf-A Sadaf-A closed this by deleting the head repository Jun 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: active filters Issues related to the Active Filters block. skip-changelog PRs that you don't want to appear in the changelog. type: community contribution type: refactor The issue/PR is related to refactoring.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace propTypes with TypeScript definitions
2 participants