Provides type definitions which can create types to validate string path against any type.
npm install lovely-typed-path-names
pnpm add lovely-typed-path-names
yarn add lovely-typed-path-names
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.
This is a pnpm project!
pnpm install
Run tests:
pnpm test
There is no build run needed. The package just exports types.