Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .changeset/6426-dashboard-test-header-compiled.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
---
---

Comment-only fix: two headers in `@object-ui/plugin-dashboard` still said this
package's tests are "compiled by nothing", a debt that has since been paid. The
paragraphs did not merely describe the old state — they prescribed against
writing a compile-time pin in this package, and nearly misrouted the legitimate
one that objectui#6373 landed a few files away.

- `src/__tests__/MetricWidget.domPassthrough.test.tsx` — the header claimed
`tsconfig.json` excludes the tests, that the package is "the sole remaining
`TEST_DEBT` entry", and that a `@ts-expect-error` written there "would be
especially dishonest".
- `src/domPassthroughPins.ts` — the counterpart half of the same contract
carried the same premise (plus a stale "6 errors, objectui#4118" count), so
fixing only the test file would have left the two halves disagreeing.

Both now state today's arrangement and name the config that does it:
`tsconfig.test.json` type-checks this package's tests, chained from the
package's `type-check` script (`tsc --noEmit && tsc -p tsconfig.test.json`).
The `src/` placement of the pins is kept and re-framed as a preference rather
than a constraint — they still belong next to the contract and still emit zero
runtime bytes, but a pin in a test file is checked now too.

Measured on this tree: `tsconfig.test.json --listFiles` includes 81 of this
package's test files (both edited-adjacent files among them);
`node scripts/check-type-check-coverage.mjs` reports `test type-check coverage:
41/41 packages compile their tests, 0 declared debt`; and an `@ts-expect-error`
injected into the test file guarding nothing is reported as
`error TS2578: Unused '@ts-expect-error' directive`.

No behaviour change, no public surface change.
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,14 +30,21 @@
* The defect was type-only — `id` / `role` / `aria-label` reached the card the
* whole time — so the fix's own direction cannot be observed by anything vitest
* runs. The compile-time assertions therefore live in `../domPassthroughPins.ts`,
* a SOURCE module the package's `tsc --noEmit` actually compiles. They are not
* here, and deliberately so: this package's tests are compiled by nothing
* (`tsconfig.json` excludes `**\/*.test.tsx`, the package is the sole remaining
* `TEST_DEBT` entry in `scripts/check-type-check-coverage.mjs`, and vitest erases
* types), which is objectui#3181 — assertions in an uncompiled test file read as
* coverage and are decoration. A `@ts-expect-error` written here would be
* especially dishonest: nothing would ever check that the error it expects still
* happens.
* a SOURCE module the package's `tsc --noEmit` compiles, next to the contract
* they pin.
*
* That split is a PREFERENCE, not a constraint — do not read it as a rule against
* compile-time assertions in this file. It was a constraint when #4426 was
* written: this package's tests were then compiled by nothing, so an assertion
* here would have read as coverage while being decoration (objectui#3181). That
* debt is paid. `tsconfig.test.json` type-checks this package's tests, this file
* included, and this package's `type-check` script chains it
* (`tsc --noEmit && tsc -p tsconfig.test.json`) — which is what CI's Type Check
* job runs. So a `@ts-expect-error` written here IS checked: when the error it
* expects stops happening, `tsc` reports it UNUSED (TS2578). Write a
* compile-time pin wherever it reads best — the sibling
* `ObjectDataTable.emitBoundary-6373.test.tsx` keeps two directives in a test
* file for exactly that reason.
*
* What IS real here, and only here: that those attributes actually land on the
* element, and that `title` does NOT. Case (c) is the one that would catch the
Expand Down
40 changes: 19 additions & 21 deletions packages/plugin-dashboard/src/domPassthroughPins.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,28 +12,26 @@
*
* ## Why these live in `src/` and not in a test file
*
* They are TYPE assertions, and this package's tests are compiled by nothing:
* `tsconfig.json` is the build and excludes `**\/*.test.tsx`,
* `@object-ui/plugin-dashboard` is the sole remaining `TEST_DEBT` entry in
* `scripts/check-type-check-coverage.mjs` (6 errors, objectui#4118), and vitest
* erases types before running. Putting them in a test file is objectui#3181
* exactly — a provably-false `Assert<Equal<1, 2>>` there passes
* `pnpm type-check` at exit 0.
* They go where this repo already puts load-bearing compile-time assertions: in
* source, next to the contract, compiled by the package's own `tsc --noEmit`.
* That is `widgets/toDomProps.ts`'s shape in `@object-ui/fields`, which binds its
* DOM whitelist to its declaration in both directions the same way. Unlike that
* file these are `type`-only, so they emit ZERO runtime bytes — which matters
* here, because #4426 is a types-only change and must stay one.
*
* The narrow `tsconfig.typetests.json` rescue hatch is NOT the answer either,
* however much the gate script's own comments read like an invitation:
* objectui#4291 retired the last six, and
* `scripts/__tests__/check-type-check-coverage.test.ts` now pins the terminal
* state as a repository-state test — "a `tsconfig.typetests.json` reappearing
* ANYWHERE turns this red". A first attempt at this change added one and CI said
* so. The gate permits the SHAPE; the ratchet forbids a new USER.
*
* So the assertions go where this repo already puts load-bearing compile-time
* assertions: in source, next to the contract, compiled by the package's own
* `tsc --noEmit`. That is `widgets/toDomProps.ts`'s shape in `@object-ui/fields`,
* which binds its DOM whitelist to its declaration in both directions the same
* way. Unlike that file these are `type`-only, so they emit ZERO runtime bytes —
* which matters here, because #4426 is a types-only change and must stay one.
* A PREFERENCE, not a constraint — though it was a constraint when this file was
* written. Then, this package's tests were compiled by nothing, so a
* provably-false `Assert<Equal<1, 2>>` in a test file passed `pnpm type-check` at
* exit 0 (objectui#3181), and the narrow `tsconfig.typetests.json` rescue hatch
* was no way round it (objectui#4291 retired the last six, and the ratchet in
* `scripts/__tests__/check-type-check-coverage.test.ts` still turns red on one
* reappearing anywhere — the gate permits the SHAPE, the ratchet forbids a new
* USER). That debt is paid, and by neither of those routes: `tsconfig.test.json`
* type-checks this package's tests and its `type-check` script chains it
* (`tsc --noEmit && tsc -p tsconfig.test.json`), so an assertion in a test file
* is checked now too. Nothing here argues against writing one — see the
* directives in `__tests__/ObjectDataTable.emitBoundary-6373.test.tsx`, which
* this package's `tsconfig.test.json` compiles.
*
* ## What each direction catches
*
Expand Down
Loading