Skip to content

Packages: Split tsconfigs for utility and mid-size packages - #81514

Merged
manzoorwanijk merged 21 commits into
trunkfrom
update/split-tsconfigs-bulk
Aug 18, 2026
Merged

manzoorwanijk merged 21 commits into
trunkfrom
update/split-tsconfigs-bulk

Conversation

@manzoorwanijk

Copy link
Copy Markdown
Member

What?

Part of #81473. Built on top of #81509.

Migrates 35 utility and mid-size packages to the split tsconfig layout.

Why?

Their TypeScript test files were never type checked; several packages leaked jest ambient types into src.

How?

  • Each package gains tsconfig.build.json plus a dev tsconfig.json; test-only type packages become package devDependencies.
  • The shared dev config includes narrow to TypeScript files, since JavaScript tests were never checked before either.
  • jest-console publishes a hand-written declarations.d.ts and emits nothing, so it becomes a single dev project; the validator learns this shape and checks such packages' dependencies in the dev project.
  • The ambient declaration for untyped @wordpress/commands moves to typings/untyped-packages with a paths mapping, since module resolution otherwise lands on built JavaScript.
  • Newly surfaced type errors are fixed where small (jest-console, priority-queue, worker-threads test typing); files with larger pre-existing errors are excluded per package with a standing comment.

Testing Instructions

npm install
npm run clean:package-types && npm run typecheck
npm run clean:package-types && npm run build
npm run lint:tsconfig
npm run test:unit -- tools/validation packages/jest-console packages/priority-queue packages/worker-threads

@github-actions github-actions Bot added [Package] Element /packages/element [Package] Date /packages/date [Package] Data /packages/data [Package] Server Side Render /packages/server-side-render [Package] A11y /packages/a11y [Package] Autop /packages/autop [Package] DOM ready /packages/dom-ready [Package] i18n /packages/i18n [Package] Word count /packages/wordcount [Package] Deprecated packages/deprecated [Package] Compose /packages/compose [Package] Core data /packages/core-data [Package] API fetch /packages/api-fetch [Package] HTML entities /packages/html-entities [Package] Viewport /packages/viewport [Package] DOM /packages/dom [Package] Keycodes /packages/keycodes [Package] Plugins /packages/plugins [Package] Components /packages/components [Package] Blocks /packages/blocks [Package] Editor /packages/editor [Package] Block library /packages/block-library [Package] Notices /packages/notices [Package] Rich text /packages/rich-text [Package] Block editor /packages/block-editor [Package] Data Controls /packages/data-controls [Package] Priority Queue /packages/priority-queue [Package] Escape HTML /packages/escape-html [Package] Primitives /packages/primitives [Package] Icons /packages/icons labels Aug 12, 2026
Comment thread tsconfig.dev.base.json Resolved
Comment thread packages/notices/tsconfig.json Resolved
Comment thread packages/compose/tsconfig.json Resolved
Comment thread tsconfig.base.json Resolved
Comment thread tsconfig.base.json Resolved
Comment thread packages/compose/CHANGELOG.md Resolved
Comment thread packages/compose/tsconfig.json Resolved
@ciampo

ciampo commented Aug 17, 2026

Copy link
Copy Markdown
Contributor
Minor comment (that I couldn't leave inline since GitHub.com is partially down):

In packages/README.md (lines 369 and following) the docs say npm run lint:tsconfig enforces both listed rules, but the validator only checks the types relationship. It does not check the required build-project exclusions. Because a package-level exclude replaces the inherited array, omitting one required pattern still passes the validator and its tests, allowing test or story declarations back into a package build.

Should we add a validator fixture where a build-project override omits one required dev-file pattern and make that case fail? Alternatively, the documentation should not claim that this invariant is enforced.

@ciampo

ciampo commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Otherwise LGTM

@manzoorwanijk

Copy link
Copy Markdown
Member Author

@ciampo That is a good catch, the docs were ahead of the code. The validator now reads the dev-file patterns from tsconfig.base.json and fails any build project whose own exclude drops one of them (2d33f99), with a fixture for the omission case and one for a complete override with a package-specific extra. So the sentence in the README is true now.

Migrates 36 packages to the build and dev project layout. Two of them
need a different shape: jest-console has no build project and becomes a
single dev project, so the tsconfig validator learns to expect such
packages in the root dev solution. The ambient declaration for untyped
@wordpress/commands moves to typings/untyped-packages with a paths
mapping, since resolution otherwise lands on built JavaScript. Test
files with pre-existing type errors are excluded per package until
fixed.
The changelog conflict resolution let the merge land entries inside
today's release sections.
The changelog check treats reference repoints as package changes.
Trunk added the dependency after the split; the rebase merged it in the
directory form that resolves to the dev project.
A package exclude replaces the inherited one, so the build projects that
listed specific files were emitting declarations for test and story
files. The dev projects now own those files and carry the types they
need.
The jest and test environment types, and the jest-dom global, served
the tests the build project no longer owns.
No notices or jest-console dev file uses the jest-dom matchers; the one
notices test that does is excluded for pre-existing type errors.
The base config enables checkJs, which would pull any JavaScript file a
dev file imports into type checking the build never did.
The stack rebases and entry moves left duplicated blocks, doubled
sections, empty headings, and missing blank lines behind.
Every split build project now lists the same five dev-file patterns, so
a future tests directory or story cannot slip into the declarations.
The dead root-relative entries copied from the base config are gone.
A dev project's types replaced the build project's, so tests could not
see globals like process.env or requestIdleCallback that the sources
under test rely on. Every dev project now starts from the build list,
the last two build projects with test types hand them over, and the
validator enforces both directions. Also completes the commands stub,
restores the notices jest-dom global so its excluded test can return,
and drops the unused jest-dom dependency of global-styles-engine.
The dev base includes them, so the build projects must exclude them.
Its global.d.ts was removed and no matcher from jest-dom is used.
The dev project only checked one test file through files plus an empty
include, which read as coverage. It now takes the shared includes and
excludes the five files with pre-existing errors, like the other
packages, so the debt is visible per file.
rootDir, declarationDir, and the src include come from the base config;
the emitted declarations are unchanged. worker-threads gains the schema.
Packages that rely on the inherited exclude, like a11y, were only
protected against test directories. With all patterns in the base, the
build projects that merely restated them drop their own lists; sync keeps
its list for a package-specific entry.
With node types, ReturnType< typeof setTimeout > resolves differently in
the tests than in the sources they cover. api-fetch, compose and
global-styles-engine have no Node usage in their tests, so the types
and the devDependencies added with the split go.
…ides

A package exclude replaces the inherited one, so a build project that
sets its own and omits a pattern would publish test or story
declarations again. The validator now reads the dev-file patterns from
tsconfig.base.json and fails any build project override that drops one,
which makes the documented rule true.
@manzoorwanijk

Copy link
Copy Markdown
Member Author

This is constantly resulting in changelog conflicts due to continuous changes in trunk to those changelog files. I am going to wrap this up asap to keep things moving.

Comment thread tsconfig.base.json
Comment on lines +59 to +60
"**/stories/**",
"**/*.story.*"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One thing to potentially follow up on: these shared story exclusions also affect packages that still use one TypeScript config. The editor, fields, icons, and image-cropper packages lose story files from TypeScript checks, and no dev config checks them either.

Should we keep these files covered by adding dev configs or by applying these exclusions only to split build configs?

Comment thread packages/compose/CHANGELOG.md Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] A11y /packages/a11y [Package] API fetch /packages/api-fetch [Package] Autop /packages/autop [Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Blocks /packages/blocks [Package] Components /packages/components [Package] Compose /packages/compose [Package] Core data /packages/core-data [Package] Data Controls /packages/data-controls [Package] Data /packages/data [Package] DataViews /packages/dataviews [Package] Date /packages/date [Package] Deprecated packages/deprecated [Package] DOM ready /packages/dom-ready [Package] DOM /packages/dom [Package] Edit Site /packages/edit-site [Package] Editor /packages/editor [Package] Element /packages/element [Package] Escape HTML /packages/escape-html [Package] Fields /packages/fields [Package] HTML entities /packages/html-entities [Package] i18n /packages/i18n [Package] Icons /packages/icons [Package] Interactivity Router /packages/interactivity-router [Package] Interactivity /packages/interactivity [Package] Keyboard Shortcuts /packages/keyboard-shortcuts [Package] Keycodes /packages/keycodes [Package] Media Utils /packages/media-utils [Package] Notices /packages/notices [Package] Plugins /packages/plugins [Package] Preferences /packages/preferences [Package] Primitives /packages/primitives [Package] Priority Queue /packages/priority-queue [Package] React i18n /packages/react-i18n [Package] Rich text /packages/rich-text [Package] Router /packages/router [Package] Server Side Render /packages/server-side-render [Package] Sync /packages/sync [Package] Theme /packages/theme [Package] UI /packages/ui [Package] Viewport /packages/viewport [Package] Word count /packages/wordcount [Type] Build Tooling Issues or PRs related to build tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants