Skip to content

Commit 5ca8d05

Browse files
committed
fix(metadata-protocol): type the test helper's type as MetaRef['type'] (#7682)
CI's TypeScript Type Check went red on my push: the metadata-protocol DEBT entry records 63 raw tsc errors and `tsc --noEmit` reported 64. The +1 was mine and real: sys-metadata-repository.package-writability.test.ts(166,21): error TS2322: Type 'string' is not assignable to type '"object" | "view" | ... | "email_template"'. `putWith`'s `opts.type` was `string`; `MetaRef['type']` is a literal union. The suite ran green under vitest either way — this package has no `typecheck` script, so its type surface is only judged by the ledger in CI, which is exactly the gap that let a widened parameter through a local run. Fixed at the source, not in the ledger: DEBT is a ratchet that may only shrink, and raising an entry for a file added in the same PR would be the worst version of that. `tsc --noEmit` now reports 63 for the package, matching the recorded entry, with zero errors attributable to either file this PR touches. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AmES43BMDg4bPrxTdi5q7t
1 parent 1bccc1d commit 5ca8d05

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎packages/metadata-protocol/src/sys-metadata-repository.package-writability.test.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
6464
// `@objectstack/objectql`: objectql DEPENDS ON this package, so that import
6565
// would close a dependency cycle turbo rejects outright.
6666
import { assertEngineDeleteDispatch, assertEngineUpdateDispatch } from '@objectstack/metadata-core';
67+
import type { MetaRef } from '@objectstack/metadata-core';
6768
import { ObjectStackProtocolImplementation } from './protocol.js';
6869
import { SysMetadataRepository, resetEnvWritableMetadataTypes } from './sys-metadata-repository.js';
6970

@@ -156,10 +157,22 @@ function makeFakeEngine() {
156157

157158
const objectBody = { name: 'showcase_task', label: 'Task', fields: { name: { type: 'text', label: 'Name' } } };
158159

159-
/** `put` with everything but the base fixed, so each case differs in ONE way. */
160+
/**
161+
* `put` with everything but the base fixed, so each case differs in ONE way.
162+
*
163+
* `type` is `MetaRef['type']`, not `string`: that field is a literal union, and
164+
* a widened `string` here is a real `tsc --noEmit` error even though `vitest`
165+
* runs the file happily (this package's type surface is judged by the DEBT
166+
* ledger in CI, never by the test run).
167+
*/
160168
async function putWith(
161169
repo: SysMetadataRepository,
162-
opts: { type: string; name: string; intent: 'override-artifact' | 'runtime-only'; packageId?: string },
170+
opts: {
171+
type: MetaRef['type'];
172+
name: string;
173+
intent: 'override-artifact' | 'runtime-only';
174+
packageId?: string;
175+
},
163176
): Promise<unknown> {
164177
return repo
165178
.put(

0 commit comments

Comments
 (0)