Widgets: Add TypeScript project config#78467
Conversation
resolve @wordpress/*, CSS module imports, and JSX in widget .tsx files
list it in the widgets Structure tree as an optional npm dependencies manifest
|
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. |
|
Flaky tests detected in 355d0ae. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26238269638
|
|
Do we need to add |
ensures CI type-checks widgets via tsgo --build
Good catch, you're right. Added This follows the setup of the other non-package-type-check configs already in that list ( |
…erg into update/widgets-tsconfig
What?
widgets/tsconfig.json, a standalone TypeScript project that covers the sources underwidgets/<name>/.package.jsonin the@wordpress/buildREADME "Structure" section.Part of #77616
Why?
widgets/had no TypeScript project of its own, so widget.tsxfiles fell back to an inferred project:@wordpress/*imports,*.module.cssimports, and JSX surfaced as errors in the editor even though the runtime code was correct. The dependency-resolution half of this gap was addressed in #78463, which gave each widget its ownpackage.json; this adds the TypeScript half.How?
widgets/tsconfig.jsonextendstsconfig.base.jsonwithjsx: "react-jsx"(automatic runtime, no React import needed),rootDir: ".",noEmitwithcomposite: false, andtypes: [ "style-imports" ]for CSS module imports.tsconfig.jsonreferences: it is a standalone type-check project, not part of the incremental build graph.package.jsonas an optional npm dependencies manifest in the widget structure tree (per review feedback on Widgets: Declare dependencies in a per-widget package.json #78463).Testing
npx tsc -p widgets/tsconfig.jsoncompletes with no errors.npm run lint:tsconfigpasses.widgets/<name>/*.tsxin the editor:@wordpress/*imports,*.module.cssimports, and JSX resolve.