Repository navigation
Upgrade @wordpress packages and @types/wordpress__block-editor to WP 6.9 - #480
jessicamgoddard wants to merge 4 commits into
Conversation
…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>
There was a problem hiding this comment.
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
Open (3)
getBlocksByName('core/post-content')returns block objects (not clientId strings). Passing… · New This test encodesgetBlocksByName()as returning a string clientId array, but the block-editor… · New The sharedtypes/block.tsnow depends on a block implementation module (../blocks/query/types),… · New
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 (andpackages-updatedist-tag) to WP 6.9 versions; updates@types/wordpress__block-editor. - Adds typed
core/block-editorselector wrappers and replaces several untyped selector usages. - Adjusts local
Blocktyping 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(); |
There was a problem hiding this comment.
@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.
| mockGetBlocksByName.mockReturnValue(['post-content-id']); | ||
| mainDedupe(); | ||
| expect(mockGetBlocks).toHaveBeenCalledWith('post-content-id'); |


Summary
@wordpress/*packages to the versions shipped with WordPress 6.9 (per npm'swp-6.9dist-tag), and bumps thepackages-updatescript's--dist-tagto match.@types/wordpress__block-editor(11.5.x) and@types/wordpress__edit-post, and reinstalls@types/wordpress__block-editorat its current (15.x) version.@types/wordpress__blocksis no longer needed since@wordpress/blocksnow ships its own type declarations.tscerrors acrossblocks/post/edit.tsx,blocks/query/edit.tsx,components/PatternSelectionModal/index.tsx, andservices/deduplicate/index.ts, bridging the official@wordpress/blocksBlocktype to this repo's simpler localBlocktype (types/block.ts) where needed.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 singlerootClientIdstring.components/PatternSelectionModal/index.tsx: a strayimport type { BlockInstance } from 'wordpress__blocks'only ever resolved by accident via a transitive@typespackage; now importsBlock as BlockInstancefrom@wordpress/blocksdirectly.Fixes #425.
Test plan
npm run check-types(tsc) passesnpm run eslintpassesnpm run stylelintpassesnpm run jestpassesnpm run buildcompletes successfullygetBlocks(root)→getBlocks(root[0])fix inservices/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 singlecore/post-contentblock. 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) — onlytsc/eslint/stylelint/jestran 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