From f8df4ebfc6b8fd92d6067cedad5ce6036c162d29 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sat, 24 May 2025 19:59:56 -0700 Subject: [PATCH] Fix typechecking for `parsePathLike` `PathLike` only includes Node.js's `Buffer` type, need to explicitly add the web API `TypedArray` (e.g., `Uint8Array`). --- src/core.js | 2 +- test/core.test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index 4756db7..6719cf3 100644 --- a/src/core.js +++ b/src/core.js @@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url'; /** * Parse and normalize a `PathLike` object into a string. * - * @param {PathLike} path A `string`, `Buffer`, or `URL` representing a path to a local file. + * @param {PathLike|ArrayBufferView} path A `string`, `Buffer`, or `URL` representing a path to a local file. * @returns {string} The normalized file path in string form. * @throws {TypeError} If `path` is not a `string`, `Buffer`, or `URL`, or it is a `URL` that is not using the `file` schema. */ diff --git a/test/core.test.js b/test/core.test.js index 94f5e8f..0376d23 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -44,6 +44,7 @@ suite('parsePathLike', { concurrency: true }, () => { for (const { name, input, output, error } of vectors) { test(name, { concurrency: true }, () => { if (error !== undefined) { + // @ts-expect-error throws(() => parsePathLike(input), error); } else { -- 2.47.3