Skip to content

Upgrade @wordpress packages and @types/wordpress__block-editor to WP 6.9 - #480

Open
jessicamgoddard wants to merge 4 commits into
developfrom
fix/425-update-block-editor-types
Open

jessicamgoddard wants to merge 4 commits into
developfrom
fix/425-update-block-editor-types

Conversation

@jessicamgoddard

@jessicamgoddard jessicamgoddard commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Updates all @wordpress/* packages to the versions shipped with WordPress 6.9 (per npm's wp-6.9 dist-tag), and bumps the packages-update script's --dist-tag to match.
  • Removes the pinned @types/wordpress__block-editor (11.5.x) and @types/wordpress__edit-post, and reinstalls @types/wordpress__block-editor at its current (15.x) version. @types/wordpress__blocks is no longer needed since @wordpress/blocks now ships its own type declarations.
  • Fixes the resulting tsc errors across blocks/post/edit.tsx, blocks/query/edit.tsx, components/PatternSelectionModal/index.tsx, and services/deduplicate/index.ts, bridging the official @wordpress/blocks Block type to this repo's simpler local Block type (types/block.ts) where needed.
  • Along the way, fixes two real bugs the stricter types caught:
    • services/deduplicate/index.ts: getBlocks() was being passed an array of client IDs (root) instead of a single client ID (root[0]) — the block-editor API expects a single rootClientId string.
    • components/PatternSelectionModal/index.tsx: a stray import type { BlockInstance } from 'wordpress__blocks' only ever resolved by accident via a transitive @types package; now imports Block as BlockInstance from @wordpress/blocks directly.
  • Adds a CHANGELOG.md entry.

Fixes #425.

Test plan

  • npm run check-types (tsc) passes
  • npm run eslint passes
  • npm run stylelint passes
  • npm run jest passes
  • npm run build completes successfully
  • Manual QA in wp-admin: confirm Query/Subquery/Post blocks still edit, pin/backfill posts correctly, and pattern selection still works
    • The one real risk is the getBlocks(root) → getBlocks(root[0]) fix in services/deduplicate/index.ts — that's an actual behavior change (previously passed an array where the WP selector expects a single client ID string), specifically in the "narrow scope to template mode" path when editing a single core/post-content block. It's very likely a correct bug fix, but I haven't manually verified it in the block editor (site editor / template editing with pinned + backfilled posts) — only tsc/eslint/stylelint/jest ran clean, and jest coverage here is thin (4 unrelated tests). I'd flag that as the one thing worth a real editor smoke-test before merging, which is already called out as unchecked in the PR's test plan.

🤖 Generated with Claude Code

jessicamgoddard and others added 4 commits September 23, 2026 10:15
…editor types

Removes the pinned @types/wordpress__block-editor (11.5.x) and
@types/wordpress__edit-post, updates all @wordpress/* packages to the
versions shipped with WordPress 6.9, and reinstalls
@types/wordpress__block-editor at its current (15.x) version to match.
@types/wordpress__blocks is no longer needed since @wordpress/blocks
now ships its own type declarations.

Fixes the resulting type errors, including two real bugs the stricter
types caught: getBlocks() in services/deduplicate was being passed an
array of client IDs instead of a single client ID, and a stray
'wordpress__blocks' import in PatternSelectionModal only resolved by
accident via a transitive @types package.

Fixes #425

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jessicamgoddard
jessicamgoddard requested a balanced review from Copilot September 30, 2026 15:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 1 High severity · 2 Medium severity

Open (3)
What changed in this PR

Updates the project to WordPress 6.9-aligned @wordpress/* packages and newer block-editor typings, then adjusts the codebase to satisfy stricter TypeScript types (including adding typed selector wrappers).

Changes:

  • Bumps @wordpress/* dependencies (and packages-update dist-tag) to WP 6.9 versions; updates @types/wordpress__block-editor.
  • Adds typed core/block-editor selector wrappers and replaces several untyped selector usages.
  • Adjusts local Block typing and fixes deduplication/type issues; adds a small Jest test for the dedupe root-selection behavior.
File Description
types/​block.ts Expands local Block attribute typing (nullable posts, terms/supportsPostTypes).
services/​deduplicate/​index.ts Uses typed selector wrappers and changes root scoping logic for template mode.
services/​deduplicate/​index.test.ts Adds tests covering dedupe’s “post-content root” scoping behavior.
services/​blockEditorSelectors/​index.ts Introduces typed wrapper helpers around block-editor selectors.
package.json Updates WP package versions and packages-update dist-tag to wp-6.9.
components/​PatternSelectionModal/​index.tsx Switches to @wordpress/blocks for Block typing.
blocks/​query/​edit.tsx Uses new typed selector helper; hardens nullability around innerBlocks.
blocks/​post/​edit.tsx Uses typed block selector wrapper; tweaks guards for drag/drop behavior.
CHANGELOG.md Notes dependency/type upgrades under “Unreleased”.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

const root: Block[] = getBlocksByName('core/post-content');
const blocks: Block[] = root.length === 1 ? getBlocks(root) : getBlocks();
const root = getBlocksByName('core/post-content');
const blocks = root.length === 1 ? getBlocks(root[0]) : getBlocks();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@copilot services/deduplicate/index.ts:136 already passes the right thing. The selector's own docs in node_modules/@wordpress/block-editor say it returns "Array of clientIds", and @types/wordpress__block-editor types it as string[]. The code and the string-array mock in the test are both correct, and "fixing" it to root[0].clientId would break dedupe.

Comment on lines +30 to +32
mockGetBlocksByName.mockReturnValue(['post-content-id']);
mainDedupe();
expect(mockGetBlocks).toHaveBeenCalledWith('post-content-id');
Comment thread types/block.ts
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.

Upgrade @types/wordpress__block-editor to latest types

2 participants