Repository navigation
Packages: Split tsconfigs for utility and mid-size packages - #81514
Conversation
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 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. |
|
Otherwise LGTM |
|
@ciampo That is a good catch, the docs were ahead of the code. The validator now reads the dev-file patterns from |
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.
|
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. |
| "**/stories/**", | ||
| "**/*.story.*" |
There was a problem hiding this comment.
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?
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?
tsconfig.build.jsonplus a devtsconfig.json; test-only type packages become package devDependencies.jest-consolepublishes a hand-writtendeclarations.d.tsand emits nothing, so it becomes a single dev project; the validator learns this shape and checks such packages' dependencies in the dev project.@wordpress/commandsmoves totypings/untyped-packageswith apathsmapping, since module resolution otherwise lands on built JavaScript.Testing Instructions