TypeScript: Bring the remaining route projects under the typecheck run - #81847
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +21 B (0%) Total Size: 7.78 MB 📦 View Changed
|
4a4747e to
705906e
Compare
e514d52 to
9a9f3dc
Compare
9a9f3dc to
40c0f24
Compare
|
Flaky tests detected in 40c0f24. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/32480480936 Should save the changes in
|
andrewserong
left a comment
There was a problem hiding this comment.
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. */ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Yes, tsconfig have always supported comments.
| editEntityRecord( | ||
| 'root', | ||
| 'site', | ||
| undefined as unknown as string, |
There was a problem hiding this comment.
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!
gutenberg/packages/core-data/src/actions.js
Line 433 in 0619247
There was a problem hiding this comment.
There is apparently some issue with TS inferring types from JSDoc. I am planning to look into it as a follow up.
| // The site entity is a singleton and has no record key. | ||
| const siteRecordKey = undefined as unknown as string; |
There was a problem hiding this comment.
Similar comment as the other one I mentioned: can this just be a plain const siteRecordKey = undefined or does it need the "as" here?
What?
Follow up to #81829. See #81473. Adds a
tsconfig.jsonto the 23 remaining route projects and registers them (plus a test project forroutes/connectors-home) in the roottsconfig.json, sonpm run typecheckchecks 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.jsonmirrors the #81829 shape, with references derived from itspackage.json. The validator now also fails when a route has TypeScript files but notsconfig.json(2 new tests).@wordpress/block-libraryjoins the untyped-packagepathsmapping, since its import resolves to built JS thatcheckJswould 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.ConfirmDialogtypes its existing__experimentalHideHeaderpassthrough;@wordpress/media-editorexports its existing frame/save-result types.Testing Instructions
npm run typecheckpasses.const bad: number = 'x';toroutes/home/route.tsand rerun: it fails.npm run lint:tsconfigpasses; deleteroutes/home/tsconfig.jsonand it fails.Use of AI Tools
Written with the help of an AI assistant, reviewed and edited by the author.