Skip to content

TypeScript: Bring the remaining route projects under the typecheck run - #81847

Merged
manzoorwanijk merged 6 commits into
trunkfrom
add/route-tsconfigs-typecheck
Aug 24, 2026
Merged

TypeScript: Bring the remaining route projects under the typecheck run#81847
manzoorwanijk merged 6 commits into
trunkfrom
add/route-tsconfigs-typecheck

Conversation

@manzoorwanijk

@manzoorwanijk manzoorwanijk commented Aug 20, 2026

Copy link
Copy Markdown
Member

What?

Follow up to #81829. See #81473. Adds a tsconfig.json to the 23 remaining route projects and registers them (plus a test project for routes/connectors-home) in the root tsconfig.json, so npm run typecheck checks every route.

Why?

These routes have TypeScript files that no project covered, so their type errors never surfaced. Putting them under the check exposed 48 real errors, fixed here.

How?

Each route tsconfig.json mirrors the #81829 shape, with references derived from its package.json. The validator now also fails when a route has TypeScript files but no tsconfig.json (2 new tests). @wordpress/block-library joins the untyped-package paths mapping, since its import resolves to built JS that checkJs would sweep in. The exposed errors are fixed with annotations, the established inline-generic pattern for entity records, narrowing, and casts where selector types fall short. ConfirmDialog types its existing __experimentalHideHeader passthrough; @wordpress/media-editor exports its existing frame/save-result types.

Testing Instructions

  1. npm run typecheck passes.
  2. Add const bad: number = 'x'; to routes/home/route.ts and rerun: it fails.
  3. npm run lint:tsconfig passes; delete routes/home/tsconfig.json and it fails.

Use of AI Tools

Written with the help of an AI assistant, reviewed and edited by the author.

@github-actions github-actions Bot added the [Package] Components /packages/components label Aug 20, 2026
@manzoorwanijk manzoorwanijk added the [Type] Code Quality Issues or PRs that relate to code quality label Aug 20, 2026
@manzoorwanijk manzoorwanijk self-assigned this Aug 20, 2026
@manzoorwanijk
manzoorwanijk marked this pull request as ready for review August 20, 2026 01:40
@manzoorwanijk
manzoorwanijk requested review from a team and ajitbohra as code owners August 20, 2026 01:40
@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown

Size Change: +21 B (0%)

Total Size: 7.78 MB

📦 View Changed
Filename Size Change
build/scripts/components/index.min.js 264 kB +21 B (+0.01%)

compressed-size-action

@manzoorwanijk
manzoorwanijk force-pushed the add/route-tsconfigs-typecheck branch from 4a4747e to 705906e Compare August 20, 2026 21:28
Comment thread packages/media-editor/src/index.ts Outdated
Comment thread packages/components/src/confirm-dialog/types.ts
@manzoorwanijk
manzoorwanijk force-pushed the add/route-tsconfigs-typecheck branch from e514d52 to 9a9f3dc Compare August 21, 2026 11:57
@manzoorwanijk
manzoorwanijk force-pushed the add/route-tsconfigs-typecheck branch from 9a9f3dc to 40c0f24 Compare August 21, 2026 12:08
@github-actions

Copy link
Copy Markdown

Flaky tests detected in 40c0f24.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/32480480936
📝 Reported tests:

Should save the changes in /test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js, passed after 2 failed attempts.
TimeoutError: page.waitForFunction: Timeout 10000ms exceeded.
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js:34:14
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=button[name="Visual"i]')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js:33:55

@manzoorwanijk
manzoorwanijk requested a review from ciampo August 24, 2026 01:19

@andrewserong andrewserong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking good to me, thanks again for the work here, it'll be a big help for those of us chipping away at various different routes 👍

Left a couple of tiny nit-picky comments, but nothing blocking. And I smoke-tested each of the routes that they're loading correctly in my local env after a fresh npm install and build. The only bugs I encountered while testing out experimental routes were already present in trunk.

LGTM! 🚀

{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../tsconfig.dev.base.json",
/* Route tests live beside the route sources, not under src. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TIL that TS config JSON files don't mind code comments! Just double-checking, though, tsc doesn't mind that this code comment is here, but do we have anything else that minds that this isn't (purely) valid JSON.

I assume it's fine since all the Github actions are passing, and the build succeeds locally.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, tsconfig have always supported comments.

Comment thread routes/identity/stage.tsx
editEntityRecord(
'root',
'site',
undefined as unknown as string,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this needed, it looks like editEntityRecord is described as supporting undefined for recordId, so I wasn't sure why we need the double as here. Apologies if I'm missing something obvious!

* @param {number|string|undefined} recordId Pass `undefined` for keyless entities.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is apparently some issue with TS inferring types from JSDoc. I am planning to look into it as a follow up.

Comment on lines +76 to +77
// The site entity is a singleton and has no record key.
const siteRecordKey = undefined as unknown as string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similar comment as the other one I mentioned: can this just be a plain const siteRecordKey = undefined or does it need the "as" here?

@manzoorwanijk
manzoorwanijk merged commit 953a217 into trunk Aug 24, 2026
65 of 70 checks passed
@manzoorwanijk
manzoorwanijk deleted the add/route-tsconfigs-typecheck branch August 24, 2026 05:17
@github-actions github-actions Bot added this to the Gutenberg 23.9 milestone Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants