From 08c8e0eae0d68be0794b4cdfc4f9635dc11dcf2e Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Tue, 13 Oct 2026 13:12:48 -0700 Subject: [PATCH] test: type the overloaded readFile mock --- tests/unit/setup/overlay-fs.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/unit/setup/overlay-fs.ts b/tests/unit/setup/overlay-fs.ts index 3cb51ee6..ed5e0873 100644 --- a/tests/unit/setup/overlay-fs.ts +++ b/tests/unit/setup/overlay-fs.ts @@ -9,12 +9,14 @@ export function clearFakeFiles() { fakeFs.clear(); } -// @ts-expect-error: I have no clue why vitest's types are wrong here vi.mock(import("node:fs/promises"), async (importOrig) => { const orig = await importOrig(); return { ...orig, - readFile: (path, options) => { + readFile: (( + path: Parameters[0], + options?: Parameters[1], + ) => { const p = path.toString(); if (fakeFs.has(p)) { const content = fakeFs.get(p)!; @@ -25,8 +27,8 @@ vi.mock(import("node:fs/promises"), async (importOrig) => { return Promise.resolve(Buffer.from(content)); } - return orig.readFile.call(this, path, options); - }, + return orig.readFile.call(this, path, options ?? null); + }) as typeof orig.readFile, access: (path, mode) => { const p = path.toString();