PathLike type
PathLike type
Section titled “PathLike type”Union of string-like inputs accepted by path constructors and helpers.
Signature:
export type PathLike = string | PurePath;References: PurePath
Remarks
Section titled “Remarks”CPython accepts both str and path objects for most APIs. The TypeScript port mirrors this behaviour by accepting plain strings alongside PurePath instances. Concrete Path objects also satisfy the contract because they extend PurePath.
Example
Section titled “Example”Accepting both strings and paths
import { Path, PathLike } from "pathlib-ts";
function ensurePath(value: PathLike): Path { return value instanceof Path ? value : new Path(value);}
const input = ensurePath("./tmp/output");console.log(input.toString());