typed-string-path
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

PathOf

Description

Sometimes we need to create a string representation of an object path:

const obj = {
  x: 2,
  y: {
    w: "abc",
    z: true,
  },
}

const path = "y.z"

This small library allows to create a string path in a typed fashion:

import { PATH, pathOf } from "typed-string-path"

...

const path = pathOf<typeof obj>().y.z[PATH]

We have intellisense while typing the path and if the object fields are renamed the path will also be renamed accordingly.

Installation

To install the stable version:

yarn install typed-string-path

Readme

Keywords

none

Package Sidebar

Install

npm i typed-string-path

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

3.48 kB

Total Files

8

Last publish

Collaborators

  • psousa50