Skip to content

Commit 2519324

Browse files
committed
tool-registry-publish: type fetchImpl test stub without an unsafe cast (CL-7096)
1 parent 391ec7b commit 2519324

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎packages/tool-registry-publish/src/publish.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
shouldPublishTarball,
1010
sha512Integrity,
1111
type ApiCall,
12+
type FetchTarballPut,
1213
} from "./publish";
1314
import { tarballsCoverRequiredSeedPackages } from "./registry";
1415

@@ -143,7 +144,7 @@ describe("publishCorbitsToolsRegistry", () => {
143144
status: 200,
144145
headers: { "Content-Type": "application/json" },
145146
},
146-
)) as typeof fetch,
147+
)) satisfies FetchTarballPut,
147148
});
148149
throw new Error("expected EmptyRegistryPublishError");
149150
} catch (cause) {

‎packages/tool-registry-publish/src/publish.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,18 @@ export async function isCorbitsToolsRegistrySeeded(
275275
);
276276
}
277277

278+
export type FetchTarballPut = (
279+
input: string,
280+
init: RequestInit,
281+
) => Promise<Response>;
282+
278283
async function putTarball(
279284
hubUrl: string,
280285
cookies: string[],
281286
tenantId: string,
282287
assetId: string,
283288
tarball: PackedTarball,
284-
fetchImpl: typeof fetch,
289+
fetchImpl: FetchTarballPut,
285290
): Promise<PublishSummary> {
286291
const headers: Record<string, string> = {
287292
"Content-Type": "application/octet-stream",
@@ -315,7 +320,7 @@ export type PublishCorbitsToolsRegistryArgs = {
315320
cookies: string[];
316321
hubUrl: string;
317322
tenantId: string;
318-
fetchImpl?: typeof fetch;
323+
fetchImpl?: FetchTarballPut;
319324
log?: (line: string) => void;
320325
/** Test seam. Production omits this and runs `checkToolPackageFreshness`. */
321326
checkFreshness?: () => Promise<void>;

0 commit comments

Comments
 (0)