Skip to content
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

Update WordPress typing packages #2841

Merged
merged 1 commit into from
Oct 8, 2024
Merged

Conversation

acicovic
Copy link
Collaborator

@acicovic acicovic commented Oct 8, 2024

Description

This PR updates the @types/wordpress__edit-post and @types/wordpress__editor packages to their latest versions, while also fixing a couple of issues that were resulting from the upgrade.

Motivation and context

Our dependency update process had become cumbersome, because dependabot was attempting to update @wordpress/edit-post and @wordpress/editor along with these type packages, which resulted in errors. As such, we had to manually do the work. Hopefully with this PR, this should be resolved.

How has this been tested?

Automated testing keeps passing.

Summary by CodeRabbit

  • New Features

    • Updated type definitions for WordPress edit post and editor modules to enhance development accuracy.
    • Introduced a clearer separation of functions into distinct interfaces for better organization and type safety.
  • Bug Fixes

    • Improved type assertions for core editor functions, enhancing clarity in function calls.

@acicovic acicovic added Component: Dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Oct 8, 2024
@acicovic acicovic added this to the 3.17.0 milestone Oct 8, 2024
@acicovic acicovic self-assigned this Oct 8, 2024
Copy link
Contributor

coderabbitai bot commented Oct 8, 2024

📝 Walkthrough

Walkthrough

The pull request includes updates to the package.json and src/@types/gutenberg/types.ts files. In package.json, the versions of two devDependencies related to WordPress type definitions were upgraded. The src/@types/gutenberg/types.ts file saw significant restructuring of type definitions, where methods were reorganized into two separate interfaces, enhancing clarity and type safety in the codebase.

Changes

File Change Summary
package.json Updated @types/wordpress__edit-post from ^7.5.7 to ^8.4.0 and @types/wordpress__editor from ^13.6.8 to ^14.3.0.
src/@types/gutenberg/types.ts Updated GutenbergFunction interface (methods removed) and added GutenbergCoreEditorFunction interface; changed type assertions for dispatchCoreEditor and dispatchCoreEditPost.

Possibly related PRs

Suggested reviewers

  • vaurdan

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@acicovic acicovic marked this pull request as ready for review October 8, 2024 12:48
@acicovic acicovic requested a review from a team as a code owner October 8, 2024 12:48
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
src/@types/gutenberg/types.ts (3)

6-7: Ensure the comment ends with a period.

The comment on line 6 does not end with a period as per WordPress coding standards, which recommend that all inline comments conclude with a period.

Apply this diff to correct the issue:

  /**
-  * Defines typings for core/block-editor functions, to avoid intellisense errors
+  * Defines typings for core/block-editor functions, to avoid intellisense errors.
   * in function calls.
   *
   * This can be removed once Gutenberg provides typings for these functions.
   *
   * @since 3.12.0
   */

37-38: Format the @since tag according to WordPress coding standards.

The @since tag on line 37 includes a description, but according to WordPress coding standards, the @since tag should only include the version number. Additional details should be moved to the main description.

Apply this diff to correct the issue:

   * This can be removed once Gutenberg provides typings for these functions.
   *
-  * @since 3.17.0 Moved from the GutenbergFunction interface.
+  * Moved from the GutenbergFunction interface.
+  *
+  * @since 3.17.0
   */

68-68: Add type annotation for clarity and type safety.

The constant dispatchCoreEditPost is defined without an explicit type annotation. To enhance code readability and maintain type safety, consider specifying the type.

Apply this diff to add the type annotation:

- export const dispatchCoreEditPost = dispatch( 'core/edit-post' );
+ export const dispatchCoreEditPost: GutenbergEditPostFunction = dispatch( 'core/edit-post' );

Replace GutenbergEditPostFunction with the appropriate type that matches the return value of dispatch( 'core/edit-post' ). If such a type doesn't exist, consider defining a new interface for it.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 411f2a9 and 65b2213.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • package.json (1 hunks)
  • src/@types/gutenberg/types.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/@types/gutenberg/types.ts (1)

Pattern **/*.{js,ts,tsx,jsx}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the code to ensure it is well-structured and adheres to best practices.
  • Verify compliance with WordPress coding standards.
  • Ensure the code is well-documented.
  • Check for security vulnerabilities and confirm the code is secure.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
  • Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
🔇 Additional comments (1)
package.json (1)

53-54: LGTM! Verify TypeScript compatibility after the update.

The updates to @types/wordpress__edit-post (7.5.7 → 8.4.0) and @types/wordpress__editor (13.6.8 → 14.3.0) align with the PR objectives. These major version updates may introduce changes in type definitions.

To ensure compatibility:

  1. Verify that the TypeScript code compiles without errors after these updates.
  2. Run the project's test suite to catch any potential issues.
  3. Review the changelogs of these packages for any breaking changes that might affect your codebase.

src/@types/gutenberg/types.ts Show resolved Hide resolved
Copy link
Contributor

@vaurdan vaurdan left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for doing this work!

@acicovic acicovic merged commit f1663aa into develop Oct 8, 2024
37 checks passed
@acicovic acicovic deleted the update/wordpress-typing-packages branch October 8, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants