Skip to content

Commit 05ac9ee

Browse files
committed
test(spec): cast the root-frame read through unknown, and assert presence
`scripts/import-prerequisite.d.mts` is partial by design and declares only the two loaders, so tsc sees a namespace without the exit-code constants and refused the direct cast (TS2352) under `check:scripts-typecheck`. The cast now goes through `unknown`, and the two `typeof` assertions are what stop a vanished export from reading as `undefined` on both sides of a comparison. Claude-Session: https://claude.ai/code/session_01UDXER3sdqfeVYpEWZs5mZx Co-authored-by: Claude <noreply@anthropic.com>
1 parent 408c915 commit 05ac9ee

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎packages/spec/scripts/dist-freshness.test.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,19 @@ describe('the prerequisite exit code, and the refusal text that explains it (#19
537537
// The drift check, against the authority rather than against a copy of it.
538538
// `packages/spec` already declares `scripts/**` in CROSS_PACKAGE_TEST_INPUTS,
539539
// so this read is inside a declared radius.
540-
const frame = (await import('../../../scripts/import-prerequisite.mjs')) as {
541-
EXIT_PREREQUISITE_NOT_MET: number;
542-
EXIT_FINDINGS: number;
540+
//
541+
// ⚠️ The cast goes through `unknown` because `scripts/import-prerequisite.d.mts`
542+
// is PARTIAL BY DESIGN — its own header says the exit-code constants are
543+
// deliberately omitted from the mirror — so tsc sees a namespace without
544+
// them. That is exactly why the two `typeof` assertions are here rather
545+
// than implied: without them the cast would make a vanished export read as
546+
// `undefined` on both sides of a comparison nobody would notice.
547+
const frame = (await import('../../../scripts/import-prerequisite.mjs')) as unknown as {
548+
EXIT_PREREQUISITE_NOT_MET?: number;
549+
EXIT_FINDINGS?: number;
543550
};
551+
expect(typeof frame.EXIT_PREREQUISITE_NOT_MET).toBe('number');
552+
expect(typeof frame.EXIT_FINDINGS).toBe('number');
544553
expect(EXIT_PREREQUISITE_NOT_MET).toBe(frame.EXIT_PREREQUISITE_NOT_MET);
545554
expect(EXIT_FINDINGS).toBe(frame.EXIT_FINDINGS);
546555
});

0 commit comments

Comments
 (0)