Skip to content

Installation

Terminal window
npm install data-path
  • Node >=20
  • TypeScript >=5.0

No special flags are required. A minimal tsconfig.json that works:

{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true
}
}

strict: true is recommended — it enables full inference through lambda parameters. Without it, some path expressions may resolve to unknown instead of the correct leaf type.

import { path } from "data-path";
type User = { name: string };
const p = path((u: User) => u.name);
console.log(p.$); // "name"

If this compiles and logs "name", the package is correctly installed.