Skip to content

lovelysystems/typed-path-names

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.