Skip to content

Commit 3570b70

Browse files
committed
fix(extension): type the realpath spy parameter as PathLike
@types/node declares promises.realpath(path: PathLike, ...); string | URL is not assignable (PathLike also admits Buffer)
1 parent ceff8bf commit 3570b70

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎src/core/webview/__tests__/webviewMessageHandler.openFile.spec.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { describe, it, expect, vi, beforeEach } from "vitest"
44
import * as nodePath from "path"
55
import * as nodeFs from "fs"
6+
import type { PathLike } from "fs"
67
import * as vscode from "vscode"
78
import { openFile } from "../../../integrations/misc/open-file"
89
import { webviewMessageHandler } from "../webviewMessageHandler"
@@ -120,7 +121,7 @@ describe("webviewMessageHandler - openFile markdown workspace containment", () =
120121
realWorld.symlinks.clear()
121122
realWorld.existing.add(WORKSPACE_ROOT)
122123
realWorld.existing.add(MOCK_CWD)
123-
vi.spyOn(nodeFs.promises, "realpath").mockImplementation(async (p: string | URL) => {
124+
vi.spyOn(nodeFs.promises, "realpath").mockImplementation(async (p: PathLike) => {
124125
const key = String(p)
125126
const symlink = realWorld.symlinks.get(key)
126127
if (symlink) {
@@ -377,7 +378,7 @@ describe("utils/pathUtils containment helpers", () => {
377378
realWorld.symlinks.clear()
378379
realWorld.existing.add(WORKSPACE_ROOT)
379380
realWorld.existing.add(MOCK_CWD)
380-
vi.spyOn(nodeFs.promises, "realpath").mockImplementation(async (p: string | URL) => {
381+
vi.spyOn(nodeFs.promises, "realpath").mockImplementation(async (p: PathLike) => {
381382
const key = String(p)
382383
const symlink = realWorld.symlinks.get(key)
383384
if (symlink) {
@@ -458,7 +459,7 @@ describe("utils/pathUtils containment helpers", () => {
458459
realWorld.existing.add(nodePath.join(MOCK_CWD, "x.ts"))
459460
const err = new Error("EACCES: permission denied")
460461
;(err as NodeJS.ErrnoException).code = "EACCES"
461-
vi.spyOn(nodeFs.promises, "realpath").mockImplementation(async (p: string | URL) => {
462+
vi.spyOn(nodeFs.promises, "realpath").mockImplementation(async (p: PathLike) => {
462463
const key = String(p)
463464
if (key === WORKSPACE_ROOT) {
464465
throw err

0 commit comments

Comments
 (0)