Skip to content

PurePath.joinpath() method

pathlib-ts > PurePath > joinpath

Produces a new path by appending additional segments to the current instance.

Signature:

joinpath<T extends PurePath>(this: T, ...segments: Array<PathLike>): T;

Parameter

Type

Description

this

T

segments

Array<PathLike>

Path fragments to append in order.

Returns:

T

A new path instance with the appended segments.

Relative segments extend the existing location, while an absolute or anchored segment replaces the accumulated path, matching CPython and Node path joining semantics. The return type preserves the concrete subclass (Posix or Windows).

Building a nested resource path

import { PurePath } from "pathlib-ts";
const project = new PurePath("/workspace");
const config = project.joinpath("packages", "docs", "astro.config.mjs");
console.log(config.toString());