From d2746aa8a47a7f8de2fc73b1dab19c9fd3c2a310 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 11 Aug 2026 20:39:33 +0000 Subject: [PATCH 1/2] test(components): type-check the whole test tree, and retire the narrow typetests project (#4040) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `@object-ui/components` gains a `tsconfig.test.json` chained from `type-check`, so its 119 test files are compiled by something for the first time. Measured at the branch point: 48 raw errors, 34 code-tier once the config-tier noise is gone — against a TEST_DEBT entry that declared 31. The registry's note for this package ("TS7006x12, TS7031x12 — untyped test callback params") turned out to be a misattribution worth recording: only TWO implicit-any sites are in the tests. The other 26 are untyped RENDERER params that appear only when a test project re-enables `noImplicitAny`, which this package's own build config deliberately disables. The new project mirrors that one flag and nothing else — a test project must not become the compiler of record for a source strictness decision `tsconfig.json` owns — and the 26 are filed as a finding rather than silently adopted or silently tightened. Of the 34, 21 are one mock-typing family: `ReturnType` resolves to the un-instantiated `Mock`, which no handler prop accepts and whose `mock.calls[0]` is the empty tuple — so eight `api.mock.calls[0][0]` assertions about the dispatched ActionDef were reading element 0 of an empty tuple. Each mock is now typed with the signature the prop it feeds declares. Three fixtures disagreed with a declared type rather than with the compiler: `renderComponent(schema: SchemaNode)` read `.type` off a union whose members include `string | number | boolean | null | undefined`; `renderInForm(onSubmit: () => void)` was handed a one-parameter event handler by all three of its callers; and the row-menu planner's `editPredicates` fixture spelled `disabledWhen`, a key the planner's parameter type does not name (filed). Per #4291's ratchet, `tsconfig.typetests.json` is retired in the same PR. Refs #4040, #4291, #3181, #3009. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3 --- .../components-type-checks-its-tests.md | 12 ++++ packages/components/package.json | 2 +- .../action-bodyExtra-forward.test.tsx | 10 +++- .../action-bodyShape-forward.test.tsx | 7 ++- .../filter-builder-no-submit.test.tsx | 9 ++- .../page-header-action-i18n.test.tsx | 9 ++- .../__tests__/page-header-actions.test.tsx | 9 ++- .../share-filter-sort-spec-parity.test.ts | 5 +- .../components/src/__tests__/test-utils.tsx | 12 +++- .../__tests__/action-forward-parity.test.tsx | 15 ++++- .../action-forward-precedence.test.tsx | 7 ++- .../action-overflow-autotrigger.test.tsx | 11 +++- .../data-table-row-menu-empty-guard.test.tsx | 15 ++++- packages/components/tsconfig.test.json | 55 +++++++++++++++++++ packages/components/tsconfig.typetests.json | 34 ------------ .../check-type-check-coverage.test.ts | 5 +- scripts/check-type-check-coverage.mjs | 14 +++-- 17 files changed, 170 insertions(+), 61 deletions(-) create mode 100644 .changeset/components-type-checks-its-tests.md create mode 100644 packages/components/tsconfig.test.json delete mode 100644 packages/components/tsconfig.typetests.json diff --git a/.changeset/components-type-checks-its-tests.md b/.changeset/components-type-checks-its-tests.md new file mode 100644 index 0000000000..151ceab484 --- /dev/null +++ b/.changeset/components-type-checks-its-tests.md @@ -0,0 +1,12 @@ +--- +--- + +chore(components): `@object-ui/components` type-checks its whole test tree. + +No published code moves. The package gains a `tsconfig.test.json` chained from +`type-check`, its 34 code-tier test errors are fixed in the tests themselves, +and the narrow `tsconfig.typetests.json` — the rescue hatch for a package still +in `TEST_DEBT` — is retired now that the full project compiles the same file +(objectui#4040 tranche 4, under objectui#4291's ratchet). The remaining +`TEST_DEBT` counts for `core` and `app-shell` are corrected to the tranche-4 +remeasurement. diff --git a/packages/components/package.json b/packages/components/package.json index 012a656582..326ba474fa 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -30,7 +30,7 @@ "prebuild": "pnpm --filter @object-ui/types build && pnpm --filter @object-ui/core build && pnpm --filter @object-ui/react build", "pretest": "pnpm run prebuild", "test": "vitest run", - "type-check": "tsc --noEmit && tsc -p tsconfig.typetests.json", + "type-check": "tsc --noEmit && tsc -p tsconfig.test.json", "lint": "eslint ." }, "dependencies": { diff --git a/packages/components/src/__tests__/action-bodyExtra-forward.test.tsx b/packages/components/src/__tests__/action-bodyExtra-forward.test.tsx index 00bf284695..422c7a941c 100644 --- a/packages/components/src/__tests__/action-bodyExtra-forward.test.tsx +++ b/packages/components/src/__tests__/action-bodyExtra-forward.test.tsx @@ -26,9 +26,10 @@ * payload was still lost downstream. */ -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest'; import { render, screen, fireEvent, waitFor } from '@testing-library/react'; import { ComponentRegistry } from '@object-ui/core'; +import type { ActionContext, ActionDef, ActionResult } from '@object-ui/core'; import { ActionProvider } from '@object-ui/react'; import '../renderers/basic/elements'; import '../renderers/action/action-button'; @@ -42,7 +43,12 @@ function Registered({ type, schema }: { type: string; schema: any }) { } describe('bodyExtra survives the renderer forward whitelist', () => { - let api: ReturnType; + // Typed with the signature `ActionProvider`'s `handlers` prop declares, not + // `ReturnType` — that resolves to the un-instantiated + // `Mock`, which no handler slot accepts and whose + // `mock.calls[0]` is the EMPTY tuple, so `dispatched()` below read `undefined` + // as far as the compiler was concerned (objectui#4040). + let api: Mock<(action: ActionDef, ctx: ActionContext) => Promise>; beforeEach(() => { api = vi.fn(async () => ({ success: true })); diff --git a/packages/components/src/__tests__/action-bodyShape-forward.test.tsx b/packages/components/src/__tests__/action-bodyShape-forward.test.tsx index e112e5cc5a..e827b7d68c 100644 --- a/packages/components/src/__tests__/action-bodyShape-forward.test.tsx +++ b/packages/components/src/__tests__/action-bodyShape-forward.test.tsx @@ -37,9 +37,10 @@ * the wrap was still dropped downstream. */ -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest'; import { render, screen, fireEvent, waitFor } from '@testing-library/react'; import { ComponentRegistry } from '@object-ui/core'; +import type { ActionContext, ActionDef, ActionResult } from '@object-ui/core'; import { ActionProvider } from '@object-ui/react'; import '../renderers/action/action-button'; import '../renderers/action/action-group'; @@ -54,7 +55,9 @@ function Registered({ type, schema }: { type: string; schema: any }) { } describe('bodyShape survives the declared-action renderer whitelists', () => { - let api: ReturnType; + // See action-bodyExtra-forward.test.tsx for why this is not + // `ReturnType` (objectui#4040). + let api: Mock<(action: ActionDef, ctx: ActionContext) => Promise>; beforeEach(() => { api = vi.fn(async () => ({ success: true })); diff --git a/packages/components/src/__tests__/filter-builder-no-submit.test.tsx b/packages/components/src/__tests__/filter-builder-no-submit.test.tsx index 23f70954e6..becbe45ce4 100644 --- a/packages/components/src/__tests__/filter-builder-no-submit.test.tsx +++ b/packages/components/src/__tests__/filter-builder-no-submit.test.tsx @@ -25,7 +25,14 @@ const FIELDS = [ { value: 'pinned', label: 'Pinned', type: 'boolean' }, ]; -function renderInForm(onSubmit: () => void, value?: any) { +// `React.FormEventHandler`, not `() => void`: every caller passes a spy that +// takes the event and calls `preventDefault()` on it, and a one-parameter +// function is not assignable to a zero-parameter one — the helper's declared +// type contradicted all three of its uses (objectui#4040). +function renderInForm( + onSubmit: React.FormEventHandler, + value?: any, +) { return render(
}) { - const onConfirm = vi.fn(async () => true); - const onToast = vi.fn(); + // Typed with the handler signatures `@object-ui/core` declares: a bare + // `vi.fn(async () => true)` is zero-arity, so `onConfirm.mock.calls[0][0]` — + // the translated message these tests exist to pin — was the empty tuple's + // element 0 as far as the compiler was concerned (objectui#4040). + const onConfirm = vi.fn(async () => true); + const onToast = vi.fn(); const handler = vi.fn(async () => ({ success: true })); const utils = render( diff --git a/packages/components/src/__tests__/page-header-actions.test.tsx b/packages/components/src/__tests__/page-header-actions.test.tsx index 2c452c97ab..23818f47c2 100644 --- a/packages/components/src/__tests__/page-header-actions.test.tsx +++ b/packages/components/src/__tests__/page-header-actions.test.tsx @@ -10,6 +10,7 @@ import { describe, it, expect, vi } from 'vitest'; import { useEffect } from 'react'; import { render, screen, fireEvent, waitFor } from '@testing-library/react'; import { ComponentRegistry } from '@object-ui/core'; +import type { ActionContext, ActionDef, ActionResult } from '@object-ui/core'; import { ActionProvider, RecordContextProvider, @@ -437,7 +438,13 @@ describe('PageHeaderRenderer — record dispatch shape (objectui#3391)', () => { record?: any; onParamCollection?: (params: any[], action?: any) => Promise | null>; }) { - const api = vi.fn(async () => ({ success: true })); + // Typed with the signature the `handlers` prop declares: a bare zero-arity + // `vi.fn` makes `api.mock.calls[0]` the empty tuple, so every + // `api.mock.calls[0][0]` below — the dispatched ActionDef, which is what + // these cases are about — was unchecked (objectui#4040). + const api = vi.fn< + (action: ActionDef, ctx: ActionContext) => Promise + >(async () => ({ success: true })); const header = ; render( diff --git a/packages/components/src/__tests__/share-filter-sort-spec-parity.test.ts b/packages/components/src/__tests__/share-filter-sort-spec-parity.test.ts index 9a34b9931d..acb35c373b 100644 --- a/packages/components/src/__tests__/share-filter-sort-spec-parity.test.ts +++ b/packages/components/src/__tests__/share-filter-sort-spec-parity.test.ts @@ -135,7 +135,10 @@ describe('renamed local dialects do not collide with a spec export', () => { /* -------------------------------------------------------------------------- */ /* Compile-time pins. A violation is a `tsc` error, not a runtime failure. */ -/* Compiled by this package's `tsconfig.typetests.json` (objectui#3181). */ +/* Compiled by this package's `tsconfig.test.json` (objectui#3181): the narrow */ +/* `tsconfig.typetests.json` that used to name this one file was the rescue */ +/* hatch for a package still in TEST_DEBT, and it was retired with the debt */ +/* (objectui#4040 / objectui#4291). */ /* -------------------------------------------------------------------------- */ type Assert = T; diff --git a/packages/components/src/__tests__/test-utils.tsx b/packages/components/src/__tests__/test-utils.tsx index 0c72a7511c..abdebb802d 100644 --- a/packages/components/src/__tests__/test-utils.tsx +++ b/packages/components/src/__tests__/test-utils.tsx @@ -8,12 +8,18 @@ import { render, RenderOptions } from '@testing-library/react'; import { ComponentRegistry } from '@object-ui/core'; -import type { SchemaNode } from '@object-ui/types'; +import type { BaseSchema } from '@object-ui/types'; /** - * Test utility for rendering components from schema + * Test utility for rendering components from schema. + * + * `BaseSchema`, not `SchemaNode`: `SchemaNode` is the union a schema TREE can + * hold — `BaseSchema | string | number | boolean | null | undefined` — and this + * helper reads `schema.type` off it, which four of those six members do not + * have. Every caller passes an object; the declared type was wider than the + * function and than anything it is used with (objectui#4040). */ -export function renderComponent(schema: SchemaNode, options?: RenderOptions) { +export function renderComponent(schema: BaseSchema, options?: RenderOptions) { const Component = ComponentRegistry.get(schema.type); if (!Component) { diff --git a/packages/components/src/renderers/action/__tests__/action-forward-parity.test.tsx b/packages/components/src/renderers/action/__tests__/action-forward-parity.test.tsx index 6d33f41e2b..5556c9e450 100644 --- a/packages/components/src/renderers/action/__tests__/action-forward-parity.test.tsx +++ b/packages/components/src/renderers/action/__tests__/action-forward-parity.test.tsx @@ -44,10 +44,16 @@ * That verdict is carried, with its evidence, in the gate's JUSTIFIED table. */ -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest'; import { render, waitFor } from '@testing-library/react'; import React from 'react'; import { ComponentRegistry } from '@object-ui/core'; +import type { + ActionContext, + ActionDef, + ActionResult, + ParamCollectionHandler, +} from '@object-ui/core'; import { ActionProvider } from '@object-ui/react'; // Module-scope side-effect imports — `action:bar` resolves its members and the // overflow menu through the ComponentRegistry at render time, and the light @@ -82,8 +88,11 @@ const CREATE = { autoTrigger: true, }; -let api: ReturnType; -let onParamCollection: ReturnType; +// Typed with the signatures the provider's props declare, not +// `ReturnType` — see action-bodyExtra-forward.test.tsx +// (objectui#4040). +let api: Mock<(action: ActionDef, ctx: ActionContext) => Promise>; +let onParamCollection: Mock; beforeEach(() => { api = vi.fn(async () => ({ success: true })); diff --git a/packages/components/src/renderers/action/__tests__/action-forward-precedence.test.tsx b/packages/components/src/renderers/action/__tests__/action-forward-precedence.test.tsx index 397c3832ba..46b8baf841 100644 --- a/packages/components/src/renderers/action/__tests__/action-forward-precedence.test.tsx +++ b/packages/components/src/renderers/action/__tests__/action-forward-precedence.test.tsx @@ -47,10 +47,11 @@ * assertion that refactor would be indistinguishable from the correct one. */ -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest'; import { render, fireEvent, waitFor } from '@testing-library/react'; import React from 'react'; import { ComponentRegistry } from '@object-ui/core'; +import type { ActionContext, ActionDef, ActionResult } from '@object-ui/core'; import { ActionProvider } from '@object-ui/react'; // Module-scope side-effect imports — the light `dom` project does not load the // `@object-ui/components` graph, and these renderers register themselves on @@ -100,7 +101,9 @@ const ICON_ORDER = [ 'locations', 'toast', 'resultDialog', ]; -let api: ReturnType; +// See action-bodyExtra-forward.test.tsx for why this is not +// `ReturnType` (objectui#4040). +let api: Mock<(action: ActionDef, ctx: ActionContext) => Promise>; beforeEach(() => { api = vi.fn(async () => ({ success: true })); diff --git a/packages/components/src/renderers/action/__tests__/action-overflow-autotrigger.test.tsx b/packages/components/src/renderers/action/__tests__/action-overflow-autotrigger.test.tsx index 948780302b..2d42249f06 100644 --- a/packages/components/src/renderers/action/__tests__/action-overflow-autotrigger.test.tsx +++ b/packages/components/src/renderers/action/__tests__/action-overflow-autotrigger.test.tsx @@ -43,10 +43,11 @@ * actions carry the flag, and only the last block tells them apart. */ -import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest'; import { render, screen, waitFor } from '@testing-library/react'; import React from 'react'; import { ComponentRegistry } from '@object-ui/core'; +import type { ActionContext, ActionDef, ActionResult } from '@object-ui/core'; import { ActionProvider } from '@object-ui/react'; // Module-scope side-effect imports — `action:bar` resolves its members (and the // overflow menu) through the ComponentRegistry at render time, and the light @@ -75,7 +76,9 @@ const CREATE = { locations: ['list_toolbar'], }; -let api: ReturnType; +// See action-bodyExtra-forward.test.tsx for why this is not +// `ReturnType` (objectui#4040). +let api: Mock<(action: ActionDef, ctx: ActionContext) => Promise>; beforeEach(() => { api = vi.fn(async () => ({ success: true })); @@ -313,7 +316,9 @@ describe('what suppresses an auto-trigger, and what does not (#4162)', () => { expect(screen.queryByRole('button', { name: 'Create Environment' })).toBeNull(); inline.unmount(); - const overflowApi = vi.fn(async () => ({ success: true })); + const overflowApi = vi.fn< + (action: ActionDef, ctx: ActionContext) => Promise + >(async () => ({ success: true })); render( diff --git a/packages/components/src/renderers/complex/__tests__/data-table-row-menu-empty-guard.test.tsx b/packages/components/src/renderers/complex/__tests__/data-table-row-menu-empty-guard.test.tsx index c5f98878b4..4de86a16da 100644 --- a/packages/components/src/renderers/complex/__tests__/data-table-row-menu-empty-guard.test.tsx +++ b/packages/components/src/renderers/complex/__tests__/data-table-row-menu-empty-guard.test.tsx @@ -28,6 +28,7 @@ import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; import React from 'react'; import { ComponentRegistry } from '@object-ui/core'; +import type { DataTableSchema } from '@object-ui/types'; import { PredicateScopeProvider } from '@object-ui/react'; import { planDataTableRowMenu } from '../data-table'; @@ -222,9 +223,21 @@ describe('planDataTableRowMenu', () => { }); it('still counts an item that renders merely DISABLED', () => { + // Typed as what the production caller actually hands the planner — + // `schema.rowEditPredicates`, whose declared shape carries `disabledWhen` + // alongside `visibleWhen` (`@object-ui/types`, objectui#2614). The planner's + // own parameter names only `visibleWhen`, because visibility is all it + // decides; a bare object literal therefore tripped excess-property checking + // once this package started type-checking its tests, while the identical + // value reaches it unremarked in production (objectui#4040). Deriving the + // annotation keeps the fixture honest about which key is being ignored, + // rather than deleting the key and quietly renaming the case. + const editPredicates: DataTableSchema['rowEditPredicates'] = { + disabledWhen: 'record.frozen == true', + }; const plan = planDataTableRowMenu({ onRowEdit: noop, - editPredicates: { disabledWhen: 'record.frozen == true' }, + editPredicates, customActions: [], row: frozen, scope, diff --git a/packages/components/tsconfig.test.json b/packages/components/tsconfig.test.json new file mode 100644 index 0000000000..34a1e2b502 --- /dev/null +++ b/packages/components/tsconfig.test.json @@ -0,0 +1,55 @@ +{ + // Type-checks this package's TESTS, which `tsconfig.json` excludes. + // See `packages/types/tsconfig.test.json` for why that exclusion was a hole: + // the build correctly keeps tests out of `dist`, but nothing else compiled + // them, so a test could assert a contract the compiler never checked. + // + // This project is now the ONLY one that compiles + // `src/__tests__/share-filter-sort-spec-parity.test.ts`, whose compile-time + // pins are erased at runtime — vitest proves nothing about them and `tsc` is + // the only thing that can (objectui#3181). A narrow `tsconfig.typetests.json` + // next door used to name that one file while the rest of the tree was in + // TEST_DEBT; the package graduated in objectui#4040 and the narrow project was + // retired with it, after `--listFiles` showed this project reads the same file + // and a provably-false `Assert` appended to it turned this project red. + // + // Chained from this package's `type-check` script, which is what the CI + // `Type Check` job runs; scripts/check-type-check-coverage.mjs enforces the + // chaining — a config nothing runs is the objectui#3009 failure itself. + "extends": "../../tsconfig.json", + "compilerOptions": { + // A checking project, never an emitting one. + "noEmit": true, + // The package build emits `dist`; this project emits nothing, so it must + // not inherit `composite` / `declaration` from the build config. + "composite": false, + "declaration": false, + "jsx": "react-jsx", + // One notch above the root's ES2020: these suites read the last emitted + // call with `calls.at(-1)`, and `Array.prototype.at` is ES2022. The + // compiler named the remedy itself. Raised HERE and not in `tsconfig.json`, + // so the package SOURCE keeps compiling against the ES2020 baseline it + // ships to. + "lib": ["ES2022", "DOM", "DOM.Iterable"], + // Naming `types` at all switches off automatic `@types/*` inclusion; + // `@testing-library/jest-dom` is listed for the matchers the DOM suites use. + "types": ["node", "@testing-library/jest-dom"], + // MIRRORS `tsconfig.json`, and only this one flag. A test file imports the + // package's own sources, so those sources are program inputs here too — and + // this package's BUILD config has `noImplicitAny: false`. Re-enabling it in + // this project would report 26 errors in `src/renderers/**` (sidebar, + // action-bar, action-menu, action-group, tree-view), i.e. it would make the + // TEST project the compiler of record for a SOURCE strictness decision that + // `tsconfig.json` owns. Those 26 are filed rather than silently adopted; + // tightening the package is a separate change to the build config, where the + // published output would actually move. + "noImplicitAny": false, + // Drop the root tsconfig's source-tree `paths` so `@object-ui/*` and + // `@objectstack/spec` resolve through the workspace dependency's built + // `.d.ts` instead of pulling sibling sources in as program inputs (TS6059). + "paths": {} + }, + // `src/**/*.d.ts` picks up `src/global.d.ts`, whose ambient declarations the + // test files rely on. + "include": ["src/**/*.test.ts", "src/**/*.test.tsx", "src/**/*.d.ts"] +} diff --git a/packages/components/tsconfig.typetests.json b/packages/components/tsconfig.typetests.json deleted file mode 100644 index f415ccd166..0000000000 --- a/packages/components/tsconfig.typetests.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - // Compiles the test file whose ENTIRE value is compile-time type assertions, - // so those assertions are actually checked by CI (objectui#3181). - // - // `src/__tests__/share-filter-sort-spec-parity.test.ts` states its claims as TYPES — - // `Assert>` is a compile error or it is nothing. The - // package's own `tsconfig.json` is the BUILD config and excludes - // `**/*.test.ts` (correctly — a test file must not emit into dist), and CI's - // only type gate drives that config, so without this project the pins would - // be the "declared != enforced" landmine objectstack#4115 exists to remove, - // sitting inside the guard for it. - // - // Chained from this package's `type-check` script, which is what the CI - // `Type Check` job runs; scripts/check-type-check-coverage.mjs enforces the - // chaining. Explicit include list, not a glob — see - // packages/app-shell/tsconfig.typetests.json for why. - "extends": "../../tsconfig.json", - "compilerOptions": { - // A checking project, never an emitting one. - "noEmit": true, - "composite": false, - "declaration": false, - "lib": ["ES2020", "DOM"], - // The parity test resolves `@objectstack/spec`'s own `.d.ts` files off disk - // (createRequire / readFileSync / node:path) to read the spec's export - // names through the TypeScript checker. - "types": ["node"], - // Drop the root tsconfig's source-tree `paths` so `@objectstack/spec` and - // the `@object-ui/*` workspace deps resolve through the real dependency - // graph rather than through sibling `src/`. - "paths": {} - }, - "include": ["src/__tests__/share-filter-sort-spec-parity.test.ts"] -} diff --git a/scripts/__tests__/check-type-check-coverage.test.ts b/scripts/__tests__/check-type-check-coverage.test.ts index 313b712390..a36b0e7070 100644 --- a/scripts/__tests__/check-type-check-coverage.test.ts +++ b/scripts/__tests__/check-type-check-coverage.test.ts @@ -519,7 +519,7 @@ describe('every surviving narrow project is a package still in debt, in this rep } }); - it('pins the six objectui#4291 retired as having none', () => { + it('pins every package whose narrow project has been retired as having none', () => { // Named rather than counted: each of these had its guard file proven covered // by `tsc -p tsconfig.test.json --listFiles`, and a provably-false `Assert` // appended to that file turned the FULL project red. A narrow project @@ -531,6 +531,9 @@ describe('every surviving narrow project is a package still in debt, in this rep '@object-ui/plugin-form', '@object-ui/plugin-grid', '@object-ui/plugin-list', + // objectui#4040 tranche 4 — retired in the same PR that graduated the + // package, which is what #4291's ratchet now requires. + '@object-ui/components', ]; for (const name of retired) { const pkg = packages.find((p) => p.name === name); diff --git a/scripts/check-type-check-coverage.mjs b/scripts/check-type-check-coverage.mjs index 392722c523..25f66b5053 100644 --- a/scripts/check-type-check-coverage.mjs +++ b/scripts/check-type-check-coverage.mjs @@ -115,10 +115,16 @@ export const TEST_DEBT = { // compile-time type assertions (objectui#3181), listed one by one so the rest // of the debt tree stays out. Both entries stay because that REST is still // unchecked — each number below is that remainder, not the whole package. - "@object-ui/core": { errors: 72, issue: 4118, note: "TS2741x32, TS2322x17 — mostly the input-vs-output fixture confusion" }, - "@object-ui/app-shell": { errors: 53, issue: 4118, note: "TS2339x24 — implementation wider than the type" }, - "@object-ui/components": { errors: 31, issue: 4118, note: "TS7006x12, TS7031x12 — untyped test callback params" }, - "@object-ui/react": { errors: 27, issue: 4118, note: "TS2769x9 — overload mismatch on render helpers" }, + // Counts REMEASURED at objectui#4040 tranche 4 against the template config + // these packages will graduate with (config-tier errors excluded). The old + // numbers were the #2911-era sweep and were unreliable in both directions — + // i18n declared 13 and measured 103, react declared 27 and measured 43 — so + // remeasure before planning against any number here. + "@object-ui/core": { errors: 56, issue: 4118, note: "TS2322x17, TS7006x10 — mostly the input-vs-output fixture confusion (was declared 72)" }, + "@object-ui/app-shell": { errors: 62, issue: 4118, note: "TS2339x8, TS2698x8, TS2739x7 — implementation wider than the type; needs lib ES2022 (was declared 53)" }, + // Graduating in the tranche-4 sibling PR; the line stays until that one lands + // so this branch's gate describes this branch. Remeasured 43 (was declared 27). + "@object-ui/react": { errors: 43, issue: 4118, note: "TS2322x18, TS2769x11 — untyped mocks and createElement children" }, "@object-ui/plugin-dashboard": { errors: 6, issue: 4118 }, }; From 07dde5e09ba407d3c2fac67c3d10776610a13cf6 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 11 Aug 2026 20:53:02 +0000 Subject: [PATCH 2/2] fix(components): type the last param-collection mock, and resolve the package self-import in the test project (#4040) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two errors CI's Type Check found that the local queue had not reached: - `page-header-actions.test.tsx`'s `onParamCollection` was the last zero-arity `vi.fn` in the file, so the assertion on the param DEFINITIONS it was handed read element 0 of the empty tuple. Typed `ParamCollectionHandler`. - `snapshot-critical.test.tsx` imports the package by its own name, the way a consumer does. With `paths: {}` that resolves through `exports` to `dist/index.d.ts` — which `type-check` must not depend on, because turbo has it wait on `^build` (dependencies), not on this package's own build. Mapped to `src/index.ts`, which is what the repo-root vitest config already aliases the same specifier to. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3 --- .../src/__tests__/page-header-actions.test.tsx | 15 +++++++++++++-- packages/components/tsconfig.test.json | 12 +++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/components/src/__tests__/page-header-actions.test.tsx b/packages/components/src/__tests__/page-header-actions.test.tsx index 23818f47c2..216fba16c4 100644 --- a/packages/components/src/__tests__/page-header-actions.test.tsx +++ b/packages/components/src/__tests__/page-header-actions.test.tsx @@ -10,7 +10,12 @@ import { describe, it, expect, vi } from 'vitest'; import { useEffect } from 'react'; import { render, screen, fireEvent, waitFor } from '@testing-library/react'; import { ComponentRegistry } from '@object-ui/core'; -import type { ActionContext, ActionDef, ActionResult } from '@object-ui/core'; +import type { + ActionContext, + ActionDef, + ActionResult, + ParamCollectionHandler, +} from '@object-ui/core'; import { ActionProvider, RecordContextProvider, @@ -490,7 +495,13 @@ describe('PageHeaderRenderer — record dispatch shape (objectui#3391)', () => { it('surfaces a spec-shaped params ARRAY as actionParams and keeps the stash through collection', async () => { const record = { id: 'rec-2' }; const paramDefs = [{ name: 'copy_ovr_start', type: 'date', required: true }]; - const onParamCollection = vi.fn(async () => ({ copy_ovr_start: '2026-01-01' })); + // Typed for the same reason as `api` above: the assertion below reads + // `onParamCollection.mock.calls[0][0]` — the param DEFINITIONS the runner + // handed the collector — which a zero-arity mock types as element 0 of the + // empty tuple (objectui#4040). + const onParamCollection = vi.fn(async () => ({ + copy_ovr_start: '2026-01-01', + })); const action = { name: 'copy_plan_params_3391', type: 'api', diff --git a/packages/components/tsconfig.test.json b/packages/components/tsconfig.test.json index 34a1e2b502..78817e643f 100644 --- a/packages/components/tsconfig.test.json +++ b/packages/components/tsconfig.test.json @@ -47,7 +47,17 @@ // Drop the root tsconfig's source-tree `paths` so `@object-ui/*` and // `@objectstack/spec` resolve through the workspace dependency's built // `.d.ts` instead of pulling sibling sources in as program inputs (TS6059). - "paths": {} + // The single entry kept is this package's OWN name: `snapshot-critical.test.tsx` + // imports it the way a consumer would, and an empty `paths` sends that + // through the package `exports` to `dist/index.d.ts` — an artifact + // `type-check` must not depend on, since turbo makes it wait on `^build` + // (the DEPENDENCIES' builds), not on this package's own. The repo-root + // vitest config aliases the same specifier to `src`, so this resolves the + // import to exactly what the test runs against. + "baseUrl": ".", + "paths": { + "@object-ui/components": ["src/index.ts"] + } }, // `src/**/*.d.ts` picks up `src/global.d.ts`, whose ambient declarations the // test files rely on.