/typed-path-names

Create path types from types

Primary LanguageTypeScriptApache License 2.0Apache-2.0

Path Type

Provides type definitions which can create types to validate string path against any type.

Installation

npm install lovely-typed-path-names
pnpm add lovely-typed-path-names
yarn add lovely-typed-path-names

Example

import { PathOfType, PropertyPathOfType } from "lovely-typed-path-names";
type MyType = {
  value: string;
  child: {
    value: number;
  };
};

type names = PathOfType<MyType>;
// names = "value" | "child" | "child.value"

type properties = PropertyPathOfType<MyType>;
// properties = "value" | "child.value"

type stringProperties = PropertyPathOfType<MyType, string>;
// stringProperties = "value"

More examples can be found in the tests.

Develop

This is a pnpm project!

pnpm install

Run tests:

pnpm test

Build

There is no build run needed. The package just exports types.