TS dev files: unchecked, or published to npm
[Type] Bug
## What problem does this address?
[`tsconfig.base.json` excludes `**/test/**`](https://github.com/WordPress/gutenberg/blob/86802246acef3fc324f311921c14359fd50303bd/tsconfig.base.json#L42): 397 TS test files across 44 packages are never checked:
```sh
$ echo "const brokenOnPurpose: number = 'not a number';" >> packages/blob/src/test/index.ts
$ npx tsc -b packages/blob --force; echo $?
0
```
```
packages/blob/src/test/index.ts(40,11): error TS2304: Cannot find name 'global'.
packages/blob/src/test/index.ts(82,31): error TS2339: Property 'toHaveStyle' does not exist on type 'JestMatchers<HTMLAnchorElement>'.
```
Stories are the inverse, type checked but shipped: the `components` tarball carries 248 story `.d.ts` files:
```sh
$ cd packages/components && npm pack --dry-run
npm notice 672B build-types/alignment-matrix-control/stories/index.story.d.ts
npm notice 422B build-types/alignment-matrix-control/stories/index.story.d.ts.map
...
```
Jest types leak into 10+ src projects; `theme` copes with five bespoke tsconfigs.
## What is your proposed solution?
Constraints:
- All TS files type checked: src, tests, stories, scripts.
- No test or story output in `build-types` or tarballs.
- Build does not check dev files.
- IDE checking works everywhere, correct ambient types.
- Jest globals never leak into src (CLI and IDE).
- Isolated installs compatible: type deps per package - #75814.
- Incremental references, low boilerplate, `lint:tsconfig` enforced, per-package migration.
Options:
- A: test projects in the root solution; build checks them.
- B (preferred): root `tsconfig.json` checks everything; build uses src-only `tsconfig.build.json`; package default configs hold dev files (jest types) and reference build configs.
- C: one root project for all dev files; unioned ambient types.
- D: strip dev output at publish; rejected, jest leaks.
- Orthogonal: emit-only builds via `--noCheck`.
4 条评论