From c740a244720dcc6b301ae85904e8fbef456593f3 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 9 Jan 2025 17:11:49 +0100 Subject: [PATCH] fix: use `node:path` export types (#199) --- src/index.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index e0c8ada..4ccb67b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,9 @@ -import type { posix as Posix, win32 as Win32, PlatformPath } from "node:path"; - import * as _path from "./_path"; export * from "./_path"; +type NodePath = typeof import("node:path"); + /** * The platform-specific file delimiter. * @@ -15,8 +15,8 @@ export const delimiter: ";" | ":" = /* @__PURE__ */ (() => // Mix namespaces without side-effects of object to allow tree-shaking const _platforms = { posix: undefined, win32: undefined } as { - posix: typeof Posix; - win32: typeof Win32; + posix: NodePath["posix"]; + win32: NodePath["win32"]; }; const mix = (del: ";" | ":" = delimiter) => { @@ -27,10 +27,11 @@ const mix = (del: ";" | ":" = delimiter) => { if (prop === "win32") return win32; return _platforms[prop] || _path[prop]; }, - }) as unknown as PlatformPath; + }) as unknown as NodePath; }; -export const posix = /* @__PURE__ */ mix(":") as typeof Posix; -export const win32 = /* @__PURE__ */ mix(";") as typeof Win32; +export const posix = /* @__PURE__ */ mix(":") as NodePath["posix"]; + +export const win32 = /* @__PURE__ */ mix(";") as NodePath["win32"]; -export default posix; +export default posix as NodePath;