diff --git a/config/ci/contract-baseline.json b/config/ci/contract-baseline.json index 439cde3c..220ad79e 100644 --- a/config/ci/contract-baseline.json +++ b/config/ci/contract-baseline.json @@ -1,11 +1,11 @@ { "schemaVersion": 1, "owner": "DongHyeonka", - "reason": "2026-11-07 소유자 결정: 템플릿 샘플 삭제. 참조 기능 시험 명령과 그 산출물, 지운 라우트의 수동 a11y 기록 산출물 4개를 뺀다", + "reason": "2026-11-07 소유자 결정: 정리 3단계(design-docs repo-structure/README.md 3.4절). 음성 타입 fixture 명령 23개를 실행기 하나(check-types-fixtures)로 합치고 check-types-recipes를 check:types:test에 넣는다", "gates": 27, - "commands": 99, - "commandReferences": 103, + "commands": 76, + "commandReferences": 80, "artifacts": 105, "stages": 5, - "gateShapeSha256": "df584fba26f8448c6a77638351c6906ed91869da82e20f12ac71ea7b2037c989" + "gateShapeSha256": "963249d0ce7771677705f8f81e82fa5524dac2e57349063f96d8136ef252881d" } diff --git a/config/ci/gates.json b/config/ci/gates.json index ab728fce..2ff619ca 100644 --- a/config/ci/gates.json +++ b/config/ci/gates.json @@ -23,169 +23,10 @@ "expect": "pass" }, { - "id": "check-types-recipes", - "script": "check:types:recipes", + "id": "check-types-fixtures", + "script": "check:types:fixtures", "expect": "pass" }, - { - "id": "check-types-fixture", - "script": "check:types:fixture", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2322:" - }, - { - "id": "check-types-fixture-ts-port", - "script": "check:types:fixture:ts-port", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2322:" - }, - { - "id": "check-types-fixture-ts-result", - "script": "check:types:fixture:ts-result", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2339:" - }, - { - "id": "check-types-fixture-application-output", - "script": "check:types:fixture:application-output", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2322:" - }, - { - "id": "check-types-fixture-application-input", - "script": "check:types:fixture:application-input", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2739:" - }, - { - "id": "check-types-fixture-feature-input", - "script": "check:types:fixture:feature-input", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2345:" - }, - { - "id": "check-types-fixture-failure-kind", - "script": "check:types:fixture:failure-kind", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2322:" - }, - { - "id": "check-types-fixture-reference-operation", - "script": "check:types:fixture:reference-operation", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2741:" - }, - { - "id": "check-types-fixture-http-operation-input", - "script": "check:types:fixture:http-operation-input", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2353:" - }, - { - "id": "check-types-fixture-http-wire-mapper", - "script": "check:types:fixture:http-wire-mapper", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2322:" - }, - { - "id": "check-types-fixture-http-operation-id", - "script": "check:types:fixture:http-operation-id", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2345:" - }, - { - "id": "check-types-fixture-http-route-id", - "script": "check:types:fixture:http-route-id", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2322:" - }, - { - "id": "check-types-fixture-feature-contribution-input", - "script": "check:types:fixture:feature-contribution-input", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2322:" - }, - { - "id": "check-types-fixture-feature-capability-selection", - "script": "check:types:fixture:feature-capability-selection", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2339:" - }, - { - "id": "check-types-fixture-direct-feature-composition", - "script": "check:types:fixture:direct-feature-composition", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2345:" - }, - { - "id": "check-types-fixture-async-overlay", - "script": "check:types:fixture:async-overlay", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2322:" - }, - { - "id": "check-types-fixture-route-runtime", - "script": "check:types:fixture:route-runtime", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2741:" - }, - { - "id": "check-types-fixture-page-action", - "script": "check:types:fixture:page-action", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS1360:" - }, - { - "id": "check-types-fixture-icon-button", - "script": "check:types:fixture:icon-button", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2741:" - }, - { - "id": "check-types-fixture-i18n-key", - "script": "check:types:fixture:i18n-key", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2345:" - }, - { - "id": "check-types-fixture-i18n-params", - "script": "check:types:fixture:i18n-params", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2554:" - }, - { - "id": "check-types-fixture-diagnostics", - "script": "check:types:fixture:diagnostics", - "expect": "pass" - }, - { - "id": "check-types-fixture-image-resolve-signal", - "script": "check:types:fixture:image-resolve-signal", - "expect": "fail", - "expectedExitCode": 1, - "expectedDiagnosticId": "error TS2741:" - }, { "id": "test-runtime-schema", "script": "test:runtime-schema", @@ -1755,30 +1596,7 @@ "name": "typecheck", "commandIds": [ "check-types", - "check-types-recipes", - "check-types-fixture", - "check-types-fixture-ts-port", - "check-types-fixture-ts-result", - "check-types-fixture-application-output", - "check-types-fixture-application-input", - "check-types-fixture-feature-input", - "check-types-fixture-failure-kind", - "check-types-fixture-reference-operation", - "check-types-fixture-http-operation-input", - "check-types-fixture-http-wire-mapper", - "check-types-fixture-http-operation-id", - "check-types-fixture-http-route-id", - "check-types-fixture-feature-contribution-input", - "check-types-fixture-feature-capability-selection", - "check-types-fixture-direct-feature-composition", - "check-types-fixture-async-overlay", - "check-types-fixture-route-runtime", - "check-types-fixture-page-action", - "check-types-fixture-icon-button", - "check-types-fixture-i18n-key", - "check-types-fixture-i18n-params", - "check-types-fixture-diagnostics", - "check-types-fixture-image-resolve-signal" + "check-types-fixtures" ], "logArtifactId": "artifact-artifacts-quality-check-types-txt", "evidenceArtifactIds": [ diff --git a/config/security/secret-scan-policy.json b/config/security/secret-scan-policy.json index adeeabe2..619d13e2 100644 --- a/config/security/secret-scan-policy.json +++ b/config/security/secret-scan-policy.json @@ -22,10 +22,8 @@ "tsconfig.app.json", "tsconfig.base.json", "tsconfig.node.json", - "tsconfig.recipes.json", "tsconfig.service-worker.json", "tsconfig.test.json", - "tsconfig.web-worker.json", "vite.config.ts", "vite.service-worker.config.ts", "vitest.config.ts", diff --git a/docs/architecture/optional-adapter-recipes.md b/docs/architecture/optional-adapter-recipes.md index 69a0483b..c1722693 100644 --- a/docs/architecture/optional-adapter-recipes.md +++ b/docs/architecture/optional-adapter-recipes.md @@ -330,7 +330,7 @@ Web Push를 함께 설치하지 않는다. ## 6. 검증 명령 ```bash -corepack pnpm check:types:recipes +corepack pnpm check:types:test corepack pnpm test:recipes corepack pnpm test:browser-capabilities corepack pnpm build diff --git a/docs/manual/01-add-a-feature.md b/docs/manual/01-add-a-feature.md index 7b33b12d..54b51178 100644 --- a/docs/manual/01-add-a-feature.md +++ b/docs/manual/01-add-a-feature.md @@ -369,7 +369,7 @@ projectRequest: (input) => Object.freeze({ - application이 React·어댑터·presentation을 import하면 `check:architecture`가 `feature-application-does-not-know-runtime`으로 막는다. - 보강 키와 조립 기여의 `featureId`가 다르면 조립이 실패한다. - 메시지: `feature adapter contribution installed an input for ` -- input 모양이 보강 타입과 다르면 `check:types`(FE-GATE-003)가 막는다. 음성 fixture `check:types:fixture:feature-input`도 같은 게이트에서 돈다. +- input 모양이 보강 타입과 다르면 `check:types`(FE-GATE-003)가 막는다. 음성 fixture `tests/fixtures/typecheck/invalid-feature-input.ts`도 같은 게이트의 `check:types:fixtures`에서 돈다. - **못 잡음**: telemetry `kind` 중복. 유일성 검사가 없다. 접두어로 피한다. ④ **쓸 스킬**: `clean-architecture`, `codebase-design` @@ -408,7 +408,7 @@ projectRequest: (input) => Object.freeze({ - presentation이 기능 `adapters/`를 import하면 `feature-presentation-does-not-know-outbound-adapters`로 막는다. - adapters가 presentation을 import하면 `feature-adapters-do-not-know-presentation`으로 막는다. - 기능 루트 파일(`feature-module.ts` 등)이나 계층이 아닌 폴더(`support/` 등)의 파일이 `src/adapters`에 닿으면 `feature-and-app-roots-do-not-reach-adapters`로 막는다. 기능 안에서 `src/adapters`에 닿을 수 있는 곳은 `adapters/` 폴더뿐이다. -- operation ID·route ID·입력 타입을 틀리면 `check:types`가 막는다. 음성 fixture: `check:types:fixture:http-operation-id`, `check:types:fixture:http-route-id`, `check:types:fixture:http-operation-input`. +- operation ID·route ID·입력 타입을 틀리면 `check:types`가 막는다. 음성 fixture: `tests/fixtures/typecheck/invalid-http-operation-id.ts`, `tests/fixtures/typecheck/invalid-http-route-id.ts`, `tests/fixtures/typecheck/invalid-http-operation-input.ts`(`check:types:fixtures`). - 호스트가 주지 않는 capability를 `needs`에 적으면 조립이 실패한다. - 메시지: `feature needs , which the host did not provide` - operation을 계약에 두고 기능 `adapters/`·`application/`에서 쓰지 않으면 `check:registries`(FE-GATE-010)가 실패한다. diff --git a/docs/operations/adapter-remediation-ledger.md b/docs/operations/adapter-remediation-ledger.md index 4c8016c6..efbeaf84 100644 --- a/docs/operations/adapter-remediation-ledger.md +++ b/docs/operations/adapter-remediation-ledger.md @@ -139,7 +139,7 @@ Rollout state starts at `NOT_STARTED`; documented-unimplemented items start at | BT-UP-05 | Refactor | `corepack pnpm exec vitest run tests/unit/resumable-upload-runtime.test.ts` | — | `NOT_PERFORMED` | characterization drift | **Attempted and reverted.** The five internal owners were extracted mechanically, but they require a shared-internals module for `RuntimeDependencies`, `ActiveResolution`, `ReconciliationResolution`, `FAILURE_CODES`, `RECOVERIES`, `reportProgress`, `observeTerminal` and ~40 further bindings to avoid an import cycle. Rather than risk the verified correctness work in this file, the extraction was reverted rather than half-landed. Behaviour and the public facade are unchanged; the file is still 2,239 lines. | | BT-UP-06 | Refactor | `corepack pnpm exec vitest run tests/unit/resumable-upload-runtime.test.ts` | `fix: drain resumable upload teardown` | `FIXED_NOT_RELEASED` | drain not quiescent | Red single-flight dispose case → green 18/18; `close()` closes admission and starts the same drain, `dispose()` aborts the active-operation registry and awaits real settlement before closing the checkpoint store | | BT-UP-07 | Documented gap (Web Locks matrix) | promotion evidence | — | `PROMOTION_BLOCKED` | n/a | — | -| BT-IMG-01 | Type-contract change | `corepack pnpm check:types:test` fixture | `fix: complete presigned capability and upload transport contracts` | `FIXED_NOT_RELEASED` | caller compile break | `resolve()` now requires the lifetime signal; `tests/fixtures/typecheck/invalid-image-cdn-resolve-signal.ts` + `check:types:fixture:image-resolve-signal` fail as designed (2 errors), and all callers pass a signal | +| BT-IMG-01 | Type-contract change | `corepack pnpm check:types:test` fixture | `fix: complete presigned capability and upload transport contracts` | `FIXED_NOT_RELEASED` | caller compile break | `resolve()` now requires the lifetime signal; `tests/fixtures/typecheck/invalid-image-cdn-resolve-signal.ts` (then its own script, merged into `check:types:fixtures` on 2026-11-08) fail as designed (2 errors), and all callers pass a signal | | BT-IMG-02 | Image probe | `corepack pnpm exec vitest run tests/unit/image-cdn-runtime.test.ts` | `fix: parse Cache-Control with quote awareness` | `FIXED_NOT_RELEASED` | Cache-Control parse rejection | Red unmatched-quote cases → green 25/25 | | BT-IMG-03 | Refactor | `corepack pnpm exec vitest run tests/unit/image-cdn-runtime.test.ts` | — | `NOT_PERFORMED` | characterization drift | **Not performed.** Same reasoning as BT-UP-05: a pure cohesion refactor of `image-cdn-runtime.ts` (1,340 lines) with no finding closure. `image-header-metadata.ts` is deliberately left intact per the review. | | BT-IMG-04 | Documented gap (descriptor provider) | promotion evidence | — | `PROMOTION_BLOCKED` | n/a | — | @@ -199,7 +199,7 @@ Captured after every correctness task landed. | `corepack pnpm test:unit` | 1 | 1585 passed / 19 failed tests; the 19 are the unchanged pre-existing `ci-artifact-contract` sandbox failures | | `corepack pnpm check:registries` | 0 | 11 registries PASS | | `corepack pnpm verify:documentation` | 0 | PASS_SCOPED | -| `corepack pnpm check:types:fixture:image-resolve-signal` | 1 | **Expected non-zero.** Negative fixture proving `resolve()` now rejects a call without a lifetime signal (BT-IMG-01). | +| 음성 fixture `invalid-image-cdn-resolve-signal.ts` 단독 tsc(그 script는 2026-11-08 `check:types:fixtures`로 합쳤다) | 1 | **Expected non-zero.** Negative fixture proving `resolve()` now rejects a call without a lifetime signal (BT-IMG-01). | `test:all` stops at `test:unit`, so the later suites above were run directly. diff --git a/docs/testing/frontend-platform-testing-strategy.md b/docs/testing/frontend-platform-testing-strategy.md index 2bf3fb19..5e3e8352 100644 --- a/docs/testing/frontend-platform-testing-strategy.md +++ b/docs/testing/frontend-platform-testing-strategy.md @@ -621,14 +621,14 @@ client route guard는 UX이며 authorization이 아님을 test 이름과 문서 공용 컴포넌트는 한 번의 결함이 모든 페이지로 전파되므로 위험도가 높다. RP-07의 실행 경로는 `check:design-system`, -`check:design-system:fixture`, `check:types:fixture:icon-button`, +`check:design-system:fixture`, `check:types:fixtures`(`invalid-icon-button.tsx`), `tests/component/design-system-platform.test.tsx`와 `tests/e2e/design-system-interactions.spec.ts`다. Story interaction/visual baseline은 VD-08/RP-10에서 추가하며 현재 runtime gallery를 isolated workshop 완료 증거로 사용하지 않는다. RP-08의 국제화 실행 경로는 `check:i18n`, `check:i18n:fixture`, -`check:types:fixture:i18n-key`, `check:types:fixture:i18n-params`, +`check:types:fixtures`(`invalid-message-key.ts`, `invalid-message-params.ts`), `tests/unit/i18n-contract.test.ts`, `tests/component/locale-platform.test.tsx`와 `tests/e2e/i18n.spec.ts`다. diff --git a/package.json b/package.json index d3d1440d..379ea823 100644 --- a/package.json +++ b/package.json @@ -26,27 +26,11 @@ "scan:dependency-advisories": "node scripts/scan-dependency-advisories.ts", "check:diagnostics": "node scripts/generate-product-feature-index.ts && node scripts/check-diagnostics.ts", "check:diagnostics:fixture": "node scripts/generate-product-feature-index.ts && node scripts/check-diagnostics.ts --fixture", - "check:types": "corepack pnpm check:types:app && corepack pnpm check:types:node && corepack pnpm check:types:test && corepack pnpm check:types:recipes && corepack pnpm check:types:web-worker && corepack pnpm check:types:service-worker", + "check:types": "corepack pnpm check:types:app && corepack pnpm check:types:node && corepack pnpm check:types:test && corepack pnpm check:types:service-worker && node scripts/check-typecheck-inputs.ts", "check:types:app": "node scripts/generate-product-feature-index.ts && tsc --project tsconfig.app.json", "check:types:node": "node scripts/generate-product-feature-index.ts && tsc --project tsconfig.node.json", "check:types:test": "node scripts/generate-product-feature-index.ts && tsc --project tsconfig.test.json", - "check:types:recipes": "node scripts/check-optional-recipe-types.ts", - "check:types:fixture": "tsc -p tests/fixtures/typecheck/tsconfig.port-call.json", - "check:types:fixture:ts-port": "tsc -p tests/fixtures/typecheck/tsconfig.port-implementation.json", - "check:types:fixture:ts-result": "tsc -p tests/fixtures/typecheck/tsconfig.result-narrowing.json", - "check:types:fixture:application-output": "tsc -p tests/fixtures/typecheck/tsconfig.application-output.json", - "check:types:fixture:application-input": "tsc -p tests/fixtures/typecheck/tsconfig.application-input.json", - "check:types:fixture:feature-input": "tsc -p tests/fixtures/typecheck/tsconfig.feature-input.json", - "check:types:fixture:failure-kind": "tsc -p tests/fixtures/typecheck/tsconfig.failure-kind.json", - "check:types:fixture:reference-operation": "tsc -p tests/fixtures/typecheck/tsconfig.reference-operation.json", - "check:types:fixture:async-overlay": "tsc -p tests/fixtures/typecheck/tsconfig.async-overlay.json", - "check:types:fixture:route-runtime": "node scripts/generate-product-feature-index.ts && tsc -p tests/fixtures/typecheck/tsconfig.route-runtime.json", - "check:types:fixture:page-action": "node scripts/generate-product-feature-index.ts && tsc -p tests/fixtures/typecheck/tsconfig.page-action.json", - "check:types:fixture:icon-button": "node scripts/generate-product-feature-index.ts && tsc -p tests/fixtures/typecheck/tsconfig.icon-button.json", - "check:types:fixture:i18n-key": "node scripts/generate-product-feature-index.ts && tsc -p tests/fixtures/typecheck/tsconfig.message-key.json", - "check:types:fixture:i18n-params": "node scripts/generate-product-feature-index.ts && tsc -p tests/fixtures/typecheck/tsconfig.message-params.json", - "check:types:fixture:diagnostics": "tsc -p tests/fixtures/typecheck/tsconfig.diagnostics-port.json", - "check:types:fixture:image-resolve-signal": "tsc -p tests/fixtures/typecheck/tsconfig.image-cdn-resolve-signal.json", + "check:types:fixtures": "node scripts/generate-product-feature-index.ts && node scripts/check-type-fixtures.ts", "test:runtime-schema": "node scripts/run-vitest.ts run tests/runtime-schema --reporter=default --reporter=junit --outputFile.junit=artifacts/tests/runtime-schema.xml --passWithNoTests", "test:unit": "node scripts/run-vitest.ts run tests/unit --reporter=default --reporter=junit --outputFile.junit=artifacts/tests/unit.xml", "test:contract": "node scripts/run-vitest.ts run tests/contract --reporter=default --reporter=junit --outputFile.junit=artifacts/tests/contract.xml", @@ -122,15 +106,7 @@ "check:ci": "corepack pnpm check:artifact-schemas && node scripts/check-ci-contract.ts && corepack pnpm check:ci-workflow", "update:ci-contract-baseline": "node scripts/update-ci-contract-baseline.ts", "verify:documentation": "node scripts/generate-product-feature-index.ts && node scripts/verify-documentation-readiness.ts", - "check:types:web-worker": "tsc --project tsconfig.web-worker.json", "check:types:service-worker": "tsc --project tsconfig.service-worker.json", - "check:types:fixture:http-operation-input": "tsc -p tests/fixtures/typecheck/tsconfig.http-operation-input.json", - "check:types:fixture:http-wire-mapper": "tsc -p tests/fixtures/typecheck/tsconfig.http-wire-mapper.json", - "check:types:fixture:http-operation-id": "tsc -p tests/fixtures/typecheck/tsconfig.http-operation-id.json", - "check:types:fixture:http-route-id": "tsc -p tests/fixtures/typecheck/tsconfig.http-route-id.json", - "check:types:fixture:feature-contribution-input": "tsc -p tests/fixtures/typecheck/tsconfig.feature-contribution-input.json", - "check:types:fixture:feature-capability-selection": "tsc -p tests/fixtures/typecheck/tsconfig.feature-capability-selection.json", - "check:types:fixture:direct-feature-composition": "tsc -p tests/fixtures/typecheck/tsconfig.direct-feature-composition.json", "generate:feature-index": "node scripts/generate-product-feature-index.ts", "create:feature": "node scripts/generate-product-feature-index.ts && node scripts/create-feature.ts", "check:feature-index": "node scripts/generate-product-feature-index.ts --check", diff --git a/scripts/check-optional-recipe-types.ts b/scripts/check-optional-recipe-types.ts deleted file mode 100644 index 9b49d6d7..00000000 --- a/scripts/check-optional-recipe-types.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { spawnSync } from "node:child_process"; -import { readdir } from "node:fs/promises"; -import { extname, resolve } from "node:path"; - -const recipeRoot = resolve("recipes"); -const pnpmCli = requireEnvironment("npm_execpath"); - -if (!(await containsTypeScriptSource(recipeRoot))) { - process.stdout.write( - "Optional recipe typecheck: SKIP (no recipe TypeScript sources installed)\n", - ); -} else { - const result = spawnSync( - process.execPath, - [pnpmCli, "exec", "tsc", "--project", "tsconfig.recipes.json"], - { stdio: "inherit" }, - ); - if (result.error) { - throw result.error; - } - process.exitCode = result.status ?? 1; -} - -function requireEnvironment(name: string): string { - const value = process.env[name]; - if (!value) { - throw new Error(`${name} is required to typecheck optional recipes`); - } - return value; -} - -async function containsTypeScriptSource(directory: string): Promise { - let entries; - try { - entries = await readdir(directory, { withFileTypes: true }); - } catch (error) { - if (hasErrorCode(error, "ENOENT")) { - return false; - } - throw error; - } - - for (const entry of entries) { - const target = resolve(directory, entry.name); - if (entry.isDirectory() && (await containsTypeScriptSource(target))) { - return true; - } - if (entry.isFile() && [".ts", ".tsx", ".mts", ".cts"].includes(extname(entry.name))) { - return true; - } - } - return false; -} - -function hasErrorCode(error: unknown, code: string): boolean { - return ( - typeof error === "object" && - error !== null && - "code" in error && - error.code === code - ); -} diff --git a/scripts/check-type-fixtures.ts b/scripts/check-type-fixtures.ts new file mode 100644 index 00000000..eaa0f655 --- /dev/null +++ b/scripts/check-type-fixtures.ts @@ -0,0 +1,141 @@ +import { spawn } from "node:child_process"; +import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +/** + * The negative type fixtures (FE-GATE-003). Each fixture under + * tests/fixtures/typecheck states on its first line what tsc must say about + * it: `// expect: TS2322` (compilation fails and reports TS2322) or + * `// expect: pass` (it compiles; tests/fixtures/typecheck/invalid-diagnostics-port.ts + * holds one `@ts-expect-error` per violation). Every fixture compiles alone + * with tests/fixtures/typecheck/tsconfig.base.json, as the 23 one-file + * tsconfigs and package scripts this runner replaces did (design-docs + * repo-structure/04-frontend-layout.md §5.3 (가)). + * + * The check is the one run-ci-gate.ts applied to each of those commands: + * tsc exits 1 and its output contains `error TS:`. A fixture without an + * expectation line fails, and so does a directory with no fixtures, so a new + * fixture cannot be skipped and an empty run cannot pass (R8). + */ + +export const TYPE_FIXTURE_ROOT = "tests/fixtures/typecheck"; +const BASE_CONFIG = `${TYPE_FIXTURE_ROOT}/tsconfig.base.json`; +/** + * tsc resolves `types` from the tsconfig's directory upwards, so the one-file + * tsconfigs are written inside the repository, in the ignored `.tmp/`. + */ +const CONFIG_ROOT = ".tmp/type-fixtures"; +const EXPECTATION = /^\/\/ expect: (pass|TS\d{4,5})$/u; +/** Helpers that fixtures import are not fixtures. */ +const FIXTURE_FILE = /^invalid-[\w-]+\.tsx?$/u; +const CONCURRENCY = 4; + +export type TypeFixtureExpectation = { kind: "pass" } | { kind: "fail"; code: string }; + +export interface TypeFixtureResult { + file: string; + expectation: TypeFixtureExpectation | undefined; + passed: boolean; + /** The diagnostic lines that met the expectation, or all output on failure. */ + evidence: string[]; +} + +export function parseTypeFixtureExpectation(source: string): TypeFixtureExpectation | undefined { + const match = EXPECTATION.exec(source.split("\n", 1)[0]?.trimEnd() ?? ""); + if (!match?.[1]) return undefined; + return match[1] === "pass" ? { kind: "pass" } : { kind: "fail", code: match[1] }; +} + +export async function listTypeFixtures(root: string): Promise { + return (await readdir(path.join(root, TYPE_FIXTURE_ROOT))) + .filter((name) => FIXTURE_FILE.test(name)) + .sort() + .map((name) => `${TYPE_FIXTURE_ROOT}/${name}`); +} + +export function judgeTypeFixture( + expectation: TypeFixtureExpectation, + exitCode: number | null, + output: string, +): Pick { + const lines = output.split("\n").filter((line) => line.trim().length > 0); + if (expectation.kind === "pass") { + return { passed: exitCode === 0, evidence: lines }; + } + const matching = lines.filter((line) => line.includes(`error ${expectation.code}:`)); + return exitCode === 1 && matching.length > 0 + ? { passed: true, evidence: matching } + : { passed: false, evidence: [`tsc exit ${exitCode}`, ...lines] }; +} + +function runTsc(root: string, config: string): Promise<{ exitCode: number | null; output: string }> { + return new Promise((resolve, reject) => { + const child = spawn(path.join(root, "node_modules/.bin/tsc"), ["--project", config, "--pretty", "false"], { + cwd: root, + stdio: ["ignore", "pipe", "pipe"], + }); + let output = ""; + child.stdout.on("data", (chunk: Buffer) => (output += chunk.toString("utf8"))); + child.stderr.on("data", (chunk: Buffer) => (output += chunk.toString("utf8"))); + child.on("error", reject); + child.on("close", (exitCode) => resolve({ exitCode, output })); + }); +} + +async function checkTypeFixture(root: string, file: string): Promise { + const expectation = parseTypeFixtureExpectation(await readFile(path.join(root, file), "utf8")); + if (!expectation) { + return { file, expectation, passed: false, evidence: ["missing `// expect:` first line"] }; + } + const config = path.join(CONFIG_ROOT, `tsconfig.${path.basename(file).replace(/\.tsx?$/u, "")}.json`); + const fromConfig = (target: string) => path.relative(path.dirname(config), target); + await writeFile( + path.join(root, config), + `${JSON.stringify({ extends: fromConfig(BASE_CONFIG), files: [fromConfig(file)] }, null, 2)}\n`, + ); + const { exitCode, output } = await runTsc(root, config); + return { file, expectation, ...judgeTypeFixture(expectation, exitCode, output) }; +} + +export async function checkTypeFixtures(root: string): Promise { + const fixtures = await listTypeFixtures(root); + await rm(path.join(root, CONFIG_ROOT), { recursive: true, force: true }); + await mkdir(path.join(root, CONFIG_ROOT), { recursive: true }); + const results: TypeFixtureResult[] = new Array(fixtures.length); + let next = 0; + await Promise.all( + Array.from({ length: Math.min(CONCURRENCY, fixtures.length) }, async () => { + while (next < fixtures.length) { + const index = next++; + results[index] = await checkTypeFixture(root, fixtures[index]!); + } + }), + ); + return results; +} + +function describeExpectation(expectation: TypeFixtureExpectation | undefined): string { + if (!expectation) return "no expectation"; + return expectation.kind === "pass" ? "expect pass" : `expect ${expectation.code}`; +} + +if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + const results = await checkTypeFixtures(process.cwd()); + for (const result of results) { + process.stdout.write( + `${result.passed ? "PASS" : "FAIL"} ${result.file} (${describeExpectation(result.expectation)})\n`, + ); + for (const line of result.evidence) process.stdout.write(` ${line}\n`); + } + const failed = results.filter(({ passed }) => !passed); + if (results.length === 0) { + process.stderr.write(`Type fixtures: FAIL (no fixtures under ${TYPE_FIXTURE_ROOT})\n`); + process.exitCode = 1; + } else if (failed.length > 0) { + process.stderr.write(`Type fixtures: FAIL (${failed.length} of ${results.length})\n`); + process.exitCode = 1; + } else { + process.stdout.write(`Type fixtures: PASS (${results.length} fixtures)\n`); + } +} diff --git a/scripts/check-typecheck-inputs.ts b/scripts/check-typecheck-inputs.ts new file mode 100644 index 00000000..a37cdee1 --- /dev/null +++ b/scripts/check-typecheck-inputs.ts @@ -0,0 +1,55 @@ +import { spawnSync } from "node:child_process"; +import { readFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +/** + * R8 of docs/manual/03-outside-feature-folder.md: a check with nothing to + * check fails. tsc passes a tsconfig whose `files` is empty when it extends + * another one, so `check:types:web-worker` compiled zero files and passed + * FE-GATE-003 from 2026-09-25 until it was deleted on 2026-11-08. Every + * tsconfig a package script hands to tsc must list at least one file of this + * repository (lib and node_modules declarations do not count). + */ + +const TSC_PROJECT = /\btsc\s+(?:--project|-p)\s+(\S+)/gu; + +export function typecheckProjects(scripts: Readonly>): string[] { + const projects = new Set(); + for (const command of Object.values(scripts)) { + for (const match of command.matchAll(TSC_PROJECT)) projects.add(match[1]!); + } + return [...projects].sort(); +} + +export function ownInputFiles(listed: string): string[] { + return listed + .split("\n") + .map((line) => line.trim()) + .filter((line) => line.length > 0 && !line.split(path.sep).includes("node_modules")); +} + +if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + const scripts = (JSON.parse(readFileSync("package.json", "utf8")) as { scripts: Record }).scripts; + const projects = typecheckProjects(scripts); + const counts = projects.map((project) => { + const result = spawnSync(path.resolve("node_modules/.bin/tsc"), ["--project", project, "--listFilesOnly"], { + encoding: "utf8", + }); + if (result.error) throw result.error; + return { project, files: ownInputFiles(result.stdout).length }; + }); + const empty = counts.filter(({ files }) => files === 0); + if (projects.length === 0 || empty.length > 0) { + process.stderr.write( + projects.length === 0 + ? "Typecheck inputs: FAIL (no package script runs tsc --project)\n" + : `Typecheck inputs: FAIL (no input files: ${empty.map(({ project }) => project).join(", ")})\n`, + ); + process.exitCode = 1; + } else { + process.stdout.write( + `Typecheck inputs: PASS (${counts.map(({ project, files }) => `${project} ${files}`).join(", ")})\n`, + ); + } +} diff --git a/scripts/lib/removal-fixture.ts b/scripts/lib/removal-fixture.ts index f3246247..0ca323c7 100644 --- a/scripts/lib/removal-fixture.ts +++ b/scripts/lib/removal-fixture.ts @@ -26,7 +26,7 @@ export const REMOVAL_FIXTURE_COPY_TARGETS = Object.freeze([ "src", "tests", "recipes", "scripts", "schemas", "config", "public", ".gitea", ".storybook", "index.html", "package.json", "tsconfig.base.json", "tsconfig.json", "tsconfig.app.json", "tsconfig.node.json", "tsconfig.test.json", - "tsconfig.recipes.json", "tsconfig.web-worker.json", "tsconfig.service-worker.json", + "tsconfig.service-worker.json", "vite.service-worker.config.ts", "vite.config.ts", "vitest.config.ts", "playwright.config.ts", "playwright.capabilities.config.ts", "playwright.dev.config.ts", "playwright.storybook.config.ts", "playwright.visual.config.ts", "eslint.config.ts", diff --git a/scripts/test-optional-recipe-removal.ts b/scripts/test-optional-recipe-removal.ts index e7bca250..78c1c90d 100644 --- a/scripts/test-optional-recipe-removal.ts +++ b/scripts/test-optional-recipe-removal.ts @@ -42,7 +42,6 @@ try { }); const removedCiScripts = new Set([ - "check:types:recipes", "test:recipes", "check:optional-recipes", "check:optional-recipes:source", diff --git a/scripts/verify-documentation-readiness.ts b/scripts/verify-documentation-readiness.ts index 5f72f0df..56fa1587 100644 --- a/scripts/verify-documentation-readiness.ts +++ b/scripts/verify-documentation-readiness.ts @@ -165,7 +165,8 @@ const DOCUMENT_INDEX = "docs/README.md"; const UNCHECKED_DOCUMENTS = new Set(["CHANGELOG.md"]); const NOT_CREATED = new Set([ // Reserved by generic-worker-has-no-network-or-credentials. The generic CPU - // worker is NOT_SELECTED (tsconfig.web-worker.json). + // worker is NOT_SELECTED; docs/manual/03-outside-feature-folder.md says how + // to add it with its own tsconfig. "src/adapters/web-worker", ]); // pnpm's own commands, which are not package scripts. diff --git a/tests/fixtures/typecheck/invalid-application-input.ts b/tests/fixtures/typecheck/invalid-application-input.ts index bf860363..d50d734d 100644 --- a/tests/fixtures/typecheck/invalid-application-input.ts +++ b/tests/fixtures/typecheck/invalid-application-input.ts @@ -1,3 +1,4 @@ +// expect: TS2739 import type { ApplicationApi } from "../../../src/application/create-application.ts"; export const incompleteApplication: ApplicationApi = { diff --git a/tests/fixtures/typecheck/invalid-application-output.ts b/tests/fixtures/typecheck/invalid-application-output.ts index 0164484f..82b64b76 100644 --- a/tests/fixtures/typecheck/invalid-application-output.ts +++ b/tests/fixtures/typecheck/invalid-application-output.ts @@ -1,3 +1,4 @@ +// expect: TS2322 import type { ApplicationOutputPorts } from "../../../src/application/create-application.ts"; export const invalidOutputPorts: ApplicationOutputPorts = { diff --git a/tests/fixtures/typecheck/invalid-async-overlay.ts b/tests/fixtures/typecheck/invalid-async-overlay.ts index a96b75b0..35601c26 100644 --- a/tests/fixtures/typecheck/invalid-async-overlay.ts +++ b/tests/fixtures/typecheck/invalid-async-overlay.ts @@ -1,3 +1,4 @@ +// expect: TS2322 import type { AsyncOverlay } from "../../../src/application/view-models/async-state.ts"; export const invalidPendingConflict: AsyncOverlay = { diff --git a/tests/fixtures/typecheck/invalid-diagnostics-port.ts b/tests/fixtures/typecheck/invalid-diagnostics-port.ts index 68861186..39498117 100644 --- a/tests/fixtures/typecheck/invalid-diagnostics-port.ts +++ b/tests/fixtures/typecheck/invalid-diagnostics-port.ts @@ -1,3 +1,4 @@ +// expect: pass import type { DiagnosticsPort } from "../../../src/application/ports/diagnostics-port.ts"; import type { TelemetryPort } from "../../../src/application/ports/telemetry-port.ts"; diff --git a/tests/fixtures/typecheck/invalid-direct-feature-composition.ts b/tests/fixtures/typecheck/invalid-direct-feature-composition.ts index 48a5d612..6d0836cf 100644 --- a/tests/fixtures/typecheck/invalid-direct-feature-composition.ts +++ b/tests/fixtures/typecheck/invalid-direct-feature-composition.ts @@ -1,3 +1,4 @@ +// expect: TS2345 import type { InstalledHttpOperationExecutor } from "../../../src/adapters/http/index.ts"; import { composeFeatureAdapterInputs } from "../../../src/features/feature-adapter-contribution.ts"; diff --git a/tests/fixtures/typecheck/invalid-failure-kind.ts b/tests/fixtures/typecheck/invalid-failure-kind.ts index b0a118d5..849417e6 100644 --- a/tests/fixtures/typecheck/invalid-failure-kind.ts +++ b/tests/fixtures/typecheck/invalid-failure-kind.ts @@ -1,3 +1,4 @@ +// expect: TS2322 import type { AppFailure } from "../../../src/contracts/errors.ts"; export const invalidFailure: AppFailure = { diff --git a/tests/fixtures/typecheck/invalid-feature-capability-selection.ts b/tests/fixtures/typecheck/invalid-feature-capability-selection.ts index ad39d7a7..1ab8aed4 100644 --- a/tests/fixtures/typecheck/invalid-feature-capability-selection.ts +++ b/tests/fixtures/typecheck/invalid-feature-capability-selection.ts @@ -1,3 +1,4 @@ +// expect: TS2339 import { defineFeatureAdapterContribution } from "../../../src/features/feature-adapter-contribution.ts"; import { createFixtureFeatureInstalledInput } from "./fixture-feature-contract.ts"; diff --git a/tests/fixtures/typecheck/invalid-feature-contribution-input.ts b/tests/fixtures/typecheck/invalid-feature-contribution-input.ts index 0f6f6490..59974e64 100644 --- a/tests/fixtures/typecheck/invalid-feature-contribution-input.ts +++ b/tests/fixtures/typecheck/invalid-feature-contribution-input.ts @@ -1,3 +1,4 @@ +// expect: TS2322 import { defineFeatureAdapterContribution } from "../../../src/features/feature-adapter-contribution.ts"; import type {} from "./fixture-feature-contract.ts"; diff --git a/tests/fixtures/typecheck/invalid-feature-input.ts b/tests/fixtures/typecheck/invalid-feature-input.ts index 23992a44..29586cbd 100644 --- a/tests/fixtures/typecheck/invalid-feature-input.ts +++ b/tests/fixtures/typecheck/invalid-feature-input.ts @@ -1,3 +1,4 @@ +// expect: TS2345 import type { ApplicationApi } from "../../../src/application/ports/in/application-api.ts"; import type { FixtureFeatureInput } from "./fixture-feature-contract.ts"; diff --git a/tests/fixtures/typecheck/invalid-http-operation-id.ts b/tests/fixtures/typecheck/invalid-http-operation-id.ts index 73fab657..97be3e03 100644 --- a/tests/fixtures/typecheck/invalid-http-operation-id.ts +++ b/tests/fixtures/typecheck/invalid-http-operation-id.ts @@ -1,3 +1,4 @@ +// expect: TS2345 import { createFeatureHttpBinding, defineFeatureHttpOperation, diff --git a/tests/fixtures/typecheck/invalid-http-operation-input.ts b/tests/fixtures/typecheck/invalid-http-operation-input.ts index 04bdec93..91f2c13a 100644 --- a/tests/fixtures/typecheck/invalid-http-operation-input.ts +++ b/tests/fixtures/typecheck/invalid-http-operation-input.ts @@ -1,3 +1,4 @@ +// expect: TS2353 import type { FixtureHttpBinding } from "./fixture-feature-contract.ts"; declare const http: FixtureHttpBinding; diff --git a/tests/fixtures/typecheck/invalid-http-route-id.ts b/tests/fixtures/typecheck/invalid-http-route-id.ts index e6afb27b..b36eaada 100644 --- a/tests/fixtures/typecheck/invalid-http-route-id.ts +++ b/tests/fixtures/typecheck/invalid-http-route-id.ts @@ -1,3 +1,4 @@ +// expect: TS2322 import { defineFeatureHttpOperationForRoutes } from "../../../src/adapters/http/index.ts"; import { mapEntityPayload, diff --git a/tests/fixtures/typecheck/invalid-http-wire-mapper.ts b/tests/fixtures/typecheck/invalid-http-wire-mapper.ts index 4be83418..53e6fcea 100644 --- a/tests/fixtures/typecheck/invalid-http-wire-mapper.ts +++ b/tests/fixtures/typecheck/invalid-http-wire-mapper.ts @@ -1,3 +1,4 @@ +// expect: TS2322 import { defineFeatureHttpOperation } from "../../../src/adapters/http/index.ts"; import { TEST_GET_ENTITY_CONTRACT } from "./fixture-feature-contract.ts"; diff --git a/tests/fixtures/typecheck/invalid-icon-button.tsx b/tests/fixtures/typecheck/invalid-icon-button.tsx index b4da306e..4aaed5a1 100644 --- a/tests/fixtures/typecheck/invalid-icon-button.tsx +++ b/tests/fixtures/typecheck/invalid-icon-button.tsx @@ -1,3 +1,4 @@ +// expect: TS2741 import { IconButton, MenuIcon } from "../../../src/presentation/design-system/index.ts"; export const InvalidIconButton = ; diff --git a/tests/fixtures/typecheck/invalid-image-cdn-resolve-signal.ts b/tests/fixtures/typecheck/invalid-image-cdn-resolve-signal.ts index 7bd47b60..d8a5b657 100644 --- a/tests/fixtures/typecheck/invalid-image-cdn-resolve-signal.ts +++ b/tests/fixtures/typecheck/invalid-image-cdn-resolve-signal.ts @@ -1,3 +1,4 @@ +// expect: TS2741 import type { ImageAssetReference, ImageCdnPresentationPort, diff --git a/tests/fixtures/typecheck/invalid-message-key.ts b/tests/fixtures/typecheck/invalid-message-key.ts index 925209fe..24eb6047 100644 --- a/tests/fixtures/typecheck/invalid-message-key.ts +++ b/tests/fixtures/typecheck/invalid-message-key.ts @@ -1,3 +1,4 @@ +// expect: TS2345 import { formatMessage } from "../../../src/presentation/i18n/index.ts"; formatMessage("ko-KR", "unknown.translation.key"); diff --git a/tests/fixtures/typecheck/invalid-message-params.ts b/tests/fixtures/typecheck/invalid-message-params.ts index 49df9774..d23f7af4 100644 --- a/tests/fixtures/typecheck/invalid-message-params.ts +++ b/tests/fixtures/typecheck/invalid-message-params.ts @@ -1,3 +1,4 @@ +// expect: TS2554 import { formatMessage } from "../../../src/presentation/i18n/index.ts"; formatMessage("en-US", "route.documentTitle"); diff --git a/tests/fixtures/typecheck/invalid-page-action.tsx b/tests/fixtures/typecheck/invalid-page-action.tsx index 94335dfb..a7b31643 100644 --- a/tests/fixtures/typecheck/invalid-page-action.tsx +++ b/tests/fixtures/typecheck/invalid-page-action.tsx @@ -1,3 +1,4 @@ +// expect: TS1360 import type { PageActionDefinition } from "../../../src/presentation/templates/index.ts"; export const activeButtonWithoutCallback = { diff --git a/tests/fixtures/typecheck/invalid-port-call.ts b/tests/fixtures/typecheck/invalid-port-call.ts index 069e87bd..d90e1eae 100644 --- a/tests/fixtures/typecheck/invalid-port-call.ts +++ b/tests/fixtures/typecheck/invalid-port-call.ts @@ -1,3 +1,4 @@ +// expect: TS2322 // This deliberately failing fixture proves that TypeScript rejects a wrong shape. function execute(request: { operationId: string }) { diff --git a/tests/fixtures/typecheck/invalid-port-implementation.ts b/tests/fixtures/typecheck/invalid-port-implementation.ts index f24f583c..2c0ba2c4 100644 --- a/tests/fixtures/typecheck/invalid-port-implementation.ts +++ b/tests/fixtures/typecheck/invalid-port-implementation.ts @@ -1,3 +1,4 @@ +// expect: TS2322 interface ClockPort { now(): number; } diff --git a/tests/fixtures/typecheck/invalid-reference-operation.ts b/tests/fixtures/typecheck/invalid-reference-operation.ts index a74abcdb..db048f53 100644 --- a/tests/fixtures/typecheck/invalid-reference-operation.ts +++ b/tests/fixtures/typecheck/invalid-reference-operation.ts @@ -1,3 +1,4 @@ +// expect: TS2741 import type { FixtureHttpBinding } from "./fixture-feature-contract.ts"; declare const http: FixtureHttpBinding; diff --git a/tests/fixtures/typecheck/invalid-result-narrowing.ts b/tests/fixtures/typecheck/invalid-result-narrowing.ts index 5821540e..e7ec22dd 100644 --- a/tests/fixtures/typecheck/invalid-result-narrowing.ts +++ b/tests/fixtures/typecheck/invalid-result-narrowing.ts @@ -1,3 +1,4 @@ +// expect: TS2339 import type { Result } from "../../../src/contracts/result.ts"; export function invalidUnwrap(result: Result): number { diff --git a/tests/fixtures/typecheck/invalid-route-runtime.ts b/tests/fixtures/typecheck/invalid-route-runtime.ts index bc8ec5e0..95d9bdf1 100644 --- a/tests/fixtures/typecheck/invalid-route-runtime.ts +++ b/tests/fixtures/typecheck/invalid-route-runtime.ts @@ -1,3 +1,4 @@ +// expect: TS2741 import { ROUTE_RUNTIME_CONTRACT } from "../../../src/features/installed-feature-contracts.ts"; type RouteId = keyof typeof ROUTE_RUNTIME_CONTRACT; diff --git a/tests/fixtures/typecheck/tsconfig.application-input.json b/tests/fixtures/typecheck/tsconfig.application-input.json deleted file mode 100644 index 481901fb..00000000 --- a/tests/fixtures/typecheck/tsconfig.application-input.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-application-input.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.application-output.json b/tests/fixtures/typecheck/tsconfig.application-output.json deleted file mode 100644 index 14ed9ff6..00000000 --- a/tests/fixtures/typecheck/tsconfig.application-output.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-application-output.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.async-overlay.json b/tests/fixtures/typecheck/tsconfig.async-overlay.json deleted file mode 100644 index ae1dc4ac..00000000 --- a/tests/fixtures/typecheck/tsconfig.async-overlay.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-async-overlay.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.diagnostics-port.json b/tests/fixtures/typecheck/tsconfig.diagnostics-port.json deleted file mode 100644 index e36df82a..00000000 --- a/tests/fixtures/typecheck/tsconfig.diagnostics-port.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-diagnostics-port.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.direct-feature-composition.json b/tests/fixtures/typecheck/tsconfig.direct-feature-composition.json deleted file mode 100644 index 81e59537..00000000 --- a/tests/fixtures/typecheck/tsconfig.direct-feature-composition.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-direct-feature-composition.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.failure-kind.json b/tests/fixtures/typecheck/tsconfig.failure-kind.json deleted file mode 100644 index 713e73fa..00000000 --- a/tests/fixtures/typecheck/tsconfig.failure-kind.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-failure-kind.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.feature-capability-selection.json b/tests/fixtures/typecheck/tsconfig.feature-capability-selection.json deleted file mode 100644 index a2fdc2cd..00000000 --- a/tests/fixtures/typecheck/tsconfig.feature-capability-selection.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-feature-capability-selection.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.feature-contribution-input.json b/tests/fixtures/typecheck/tsconfig.feature-contribution-input.json deleted file mode 100644 index 287af83f..00000000 --- a/tests/fixtures/typecheck/tsconfig.feature-contribution-input.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-feature-contribution-input.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.feature-input.json b/tests/fixtures/typecheck/tsconfig.feature-input.json deleted file mode 100644 index ce3ac52e..00000000 --- a/tests/fixtures/typecheck/tsconfig.feature-input.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-feature-input.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.http-operation-id.json b/tests/fixtures/typecheck/tsconfig.http-operation-id.json deleted file mode 100644 index 98083038..00000000 --- a/tests/fixtures/typecheck/tsconfig.http-operation-id.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-http-operation-id.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.http-operation-input.json b/tests/fixtures/typecheck/tsconfig.http-operation-input.json deleted file mode 100644 index 5c1b229e..00000000 --- a/tests/fixtures/typecheck/tsconfig.http-operation-input.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-http-operation-input.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.http-route-id.json b/tests/fixtures/typecheck/tsconfig.http-route-id.json deleted file mode 100644 index c37d1f7b..00000000 --- a/tests/fixtures/typecheck/tsconfig.http-route-id.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-http-route-id.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.http-wire-mapper.json b/tests/fixtures/typecheck/tsconfig.http-wire-mapper.json deleted file mode 100644 index b6bc81c3..00000000 --- a/tests/fixtures/typecheck/tsconfig.http-wire-mapper.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-http-wire-mapper.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.icon-button.json b/tests/fixtures/typecheck/tsconfig.icon-button.json deleted file mode 100644 index 3efcca1a..00000000 --- a/tests/fixtures/typecheck/tsconfig.icon-button.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-icon-button.tsx" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.image-cdn-resolve-signal.json b/tests/fixtures/typecheck/tsconfig.image-cdn-resolve-signal.json deleted file mode 100644 index 7fff2d6c..00000000 --- a/tests/fixtures/typecheck/tsconfig.image-cdn-resolve-signal.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-image-cdn-resolve-signal.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.message-key.json b/tests/fixtures/typecheck/tsconfig.message-key.json deleted file mode 100644 index 4e28e223..00000000 --- a/tests/fixtures/typecheck/tsconfig.message-key.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-message-key.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.message-params.json b/tests/fixtures/typecheck/tsconfig.message-params.json deleted file mode 100644 index 809efc3f..00000000 --- a/tests/fixtures/typecheck/tsconfig.message-params.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-message-params.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.page-action.json b/tests/fixtures/typecheck/tsconfig.page-action.json deleted file mode 100644 index 4a87502b..00000000 --- a/tests/fixtures/typecheck/tsconfig.page-action.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-page-action.tsx" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.port-call.json b/tests/fixtures/typecheck/tsconfig.port-call.json deleted file mode 100644 index 00cd5818..00000000 --- a/tests/fixtures/typecheck/tsconfig.port-call.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-port-call.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.port-implementation.json b/tests/fixtures/typecheck/tsconfig.port-implementation.json deleted file mode 100644 index 5156ee8a..00000000 --- a/tests/fixtures/typecheck/tsconfig.port-implementation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-port-implementation.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.reference-operation.json b/tests/fixtures/typecheck/tsconfig.reference-operation.json deleted file mode 100644 index 1a26faae..00000000 --- a/tests/fixtures/typecheck/tsconfig.reference-operation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-reference-operation.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.result-narrowing.json b/tests/fixtures/typecheck/tsconfig.result-narrowing.json deleted file mode 100644 index 2a61c5aa..00000000 --- a/tests/fixtures/typecheck/tsconfig.result-narrowing.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-result-narrowing.ts" - ] -} diff --git a/tests/fixtures/typecheck/tsconfig.route-runtime.json b/tests/fixtures/typecheck/tsconfig.route-runtime.json deleted file mode 100644 index 0f13ec7c..00000000 --- a/tests/fixtures/typecheck/tsconfig.route-runtime.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "files": [ - "./invalid-route-runtime.ts" - ] -} diff --git a/tests/unit/ci-workflow-generation.test.ts b/tests/unit/ci-workflow-generation.test.ts index d8dae090..cd1392ce 100644 --- a/tests/unit/ci-workflow-generation.test.ts +++ b/tests/unit/ci-workflow-generation.test.ts @@ -196,9 +196,9 @@ describe("CI gate contract", () => { ).filter((gateId) => gateId !== "FE-GATE-016"), ); expect(contract.jobs).toHaveLength(10); - expect(contract.commands).toHaveLength(99); - expect(contract.gates.reduce((total, gate) => total + gate.commandIds.length, 0)).toBe(103); - expect(contract.commands.filter(({ expect }) => expect === "fail")).toHaveLength(30); + expect(contract.commands).toHaveLength(76); + expect(contract.gates.reduce((total, gate) => total + gate.commandIds.length, 0)).toBe(80); + expect(contract.commands.filter(({ expect }) => expect === "fail")).toHaveLength(8); expect(contract.gates.reduce((total, gate) => total + gate.evidenceArtifactIds.length, 0)).toBe(83); expect(contract.artifacts).toHaveLength(105); expect(contract.stages).toHaveLength(5); diff --git a/tests/unit/feature-scaffold-drill.test.ts b/tests/unit/feature-scaffold-drill.test.ts index 603118db..1b1911fe 100644 --- a/tests/unit/feature-scaffold-drill.test.ts +++ b/tests/unit/feature-scaffold-drill.test.ts @@ -38,8 +38,8 @@ describe("feature scaffold drill commands", () => { it("keeps a negative fixture's registered exit and diagnostic", async () => { const contract = await loadCiGateContract(process.cwd()); - expect(scaffoldDrillCommands(contract).find(({ script }) => script === "check:types:fixture")) - .toMatchObject({ expectation: { kind: "fail", expectedExitCode: 1, expectedDiagnosticId: "error TS2322:" } }); + expect(scaffoldDrillCommands(contract).find(({ script }) => script === "check:coverage:fixture")) + .toMatchObject({ expectation: { kind: "fail", expectedExitCode: 1, expectedDiagnosticId: "Risk coverage failed:" } }); }); it("runs a command added to the merge stage without an edit to the drill", async () => { diff --git a/tests/unit/product-index-entrypoints.test.ts b/tests/unit/product-index-entrypoints.test.ts index dea64a61..617423be 100644 --- a/tests/unit/product-index-entrypoints.test.ts +++ b/tests/unit/product-index-entrypoints.test.ts @@ -14,11 +14,8 @@ const NON_NODE_ENTRY_SCRIPTS = [ "check:types:app", "check:types:node", "check:types:test", - "check:types:fixture:route-runtime", - "check:types:fixture:page-action", - "check:types:fixture:icon-button", - "check:types:fixture:i18n-key", - "check:types:fixture:i18n-params", + // Its fixtures, compiled through the TypeScript API, import the index. + "check:types:fixtures", ] as const; const ROOT = process.cwd(); diff --git a/tests/unit/supply-chain.test.ts b/tests/unit/supply-chain.test.ts index bd3d614e..2f8e05c7 100644 --- a/tests/unit/supply-chain.test.ts +++ b/tests/unit/supply-chain.test.ts @@ -564,10 +564,8 @@ describe("supply-chain policy", () => { "tsconfig.app.json", "tsconfig.base.json", "tsconfig.node.json", - "tsconfig.recipes.json", "tsconfig.service-worker.json", "tsconfig.test.json", - "tsconfig.web-worker.json", ]; expect(policy.trackedRoots).toEqual( expect.arrayContaining(mandatory.filter((input) => existsSync(input))), diff --git a/tests/unit/type-fixtures.test.ts b/tests/unit/type-fixtures.test.ts new file mode 100644 index 00000000..69aca025 --- /dev/null +++ b/tests/unit/type-fixtures.test.ts @@ -0,0 +1,70 @@ +import { readFile } from "node:fs/promises"; + +import { describe, expect, it } from "vitest"; + +import { + judgeTypeFixture, + listTypeFixtures, + parseTypeFixtureExpectation, +} from "../../scripts/check-type-fixtures.ts"; +import { ownInputFiles, typecheckProjects } from "../../scripts/check-typecheck-inputs.ts"; + +describe("negative type fixtures (FE-GATE-003)", () => { + it("reads the expectation from the first line only", () => { + expect(parseTypeFixtureExpectation("// expect: TS2322\nconst a = 1;")).toEqual({ kind: "fail", code: "TS2322" }); + expect(parseTypeFixtureExpectation("// expect: pass\n")).toEqual({ kind: "pass" }); + expect(parseTypeFixtureExpectation("import x from './x';\n// expect: TS2322\n")).toBeUndefined(); + expect(parseTypeFixtureExpectation("// expect: 2322\n")).toBeUndefined(); + }); + + it("states an expectation in every fixture", async () => { + const fixtures = await listTypeFixtures(process.cwd()); + expect(fixtures.length).toBeGreaterThan(0); + for (const fixture of fixtures) { + expect(parseTypeFixtureExpectation(await readFile(fixture, "utf8")), fixture).toBeDefined(); + } + }); + + // run-ci-gate.ts applied the same test to each of the 23 commands this + // runner replaced: exit 1 and the registered `error TS:` in the output. + it("passes a failing fixture only on exit 1 with the expected code", () => { + const fail = { kind: "fail", code: "TS2322" } as const; + const output = "a.ts(1,7): error TS2322: Type 'number' is not assignable to type 'string'.\n"; + expect(judgeTypeFixture(fail, 1, output)).toEqual({ + passed: true, + evidence: ["a.ts(1,7): error TS2322: Type 'number' is not assignable to type 'string'."], + }); + expect(judgeTypeFixture(fail, 1, "a.ts(1,7): error TS2339: Property 'x' does not exist.\n").passed).toBe(false); + expect(judgeTypeFixture(fail, 0, "").passed).toBe(false); + expect(judgeTypeFixture(fail, 2, output).passed).toBe(false); + }); + + // 07-05. A port type that widens leaves an `@ts-expect-error` unused (TS2578). + it("fails a fixture expected to compile when tsc reports anything", () => { + expect(judgeTypeFixture({ kind: "pass" }, 0, "").passed).toBe(true); + expect( + judgeTypeFixture({ kind: "pass" }, 1, "a.ts(20,1): error TS2578: Unused '@ts-expect-error' directive.\n"), + ).toEqual({ passed: false, evidence: ["a.ts(20,1): error TS2578: Unused '@ts-expect-error' directive."] }); + }); +}); + +describe("typecheck inputs (R8)", () => { + it("finds every tsconfig a package script hands to tsc", () => { + expect( + typecheckProjects({ + app: "node gen.ts && tsc --project tsconfig.app.json", + sw: "tsc -p tsconfig.sw.json", + lint: "eslint .", + }), + ).toEqual(["tsconfig.app.json", "tsconfig.sw.json"]); + }); + + it("counts only this repository's files", () => { + expect( + ownInputFiles( + "/repo/node_modules/typescript/lib/lib.es5.d.ts\n/repo/node_modules/@types/node/index.d.ts\n/repo/src/app.ts\n", + ), + ).toEqual(["/repo/src/app.ts"]); + expect(ownInputFiles("/repo/node_modules/typescript/lib/lib.es5.d.ts\n")).toEqual([]); + }); +}); diff --git a/tsconfig.json b/tsconfig.json index 76e73be3..05f6d79c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,8 +4,6 @@ { "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }, { "path": "./tsconfig.test.json" }, - { "path": "./tsconfig.recipes.json" }, - { "path": "./tsconfig.web-worker.json" }, { "path": "./tsconfig.service-worker.json" } ] } diff --git a/tsconfig.recipes.json b/tsconfig.recipes.json deleted file mode 100644 index e2601f9f..00000000 --- a/tsconfig.recipes.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "compilerOptions": { - "lib": ["ES2022", "DOM", "DOM.Iterable"], - "types": ["node"] - }, - "include": ["recipes/**/*.ts"], - "exclude": ["dist", "node_modules"] -} diff --git a/tsconfig.test.json b/tsconfig.test.json index 85e00a5c..ffccc065 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -7,6 +7,7 @@ "include": [ "tests/**/*.ts", "tests/**/*.tsx", + "recipes/**/*.ts", "vitest.config.ts", "playwright*.config.ts" ], diff --git a/tsconfig.web-worker.json b/tsconfig.web-worker.json deleted file mode 100644 index 8d3399ca..00000000 --- a/tsconfig.web-worker.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "compilerOptions": { - "lib": ["ES2022", "WebWorker"], - "types": [], - "skipLibCheck": false - }, - "//": "§16.2 Generic CPU Worker is NOT_SELECTED: src/adapters/web-worker does not exist yet. Add it to include when a task group is contributed.", - "files": [] -}