0.0.5 • Published 3 years ago
ts-powertypes v0.0.5
ts-powertypes
Collection of typescript types
This package is work in progress and semantic versioning is not yet guaranteed. If you use this package, please make sure to set explcit version number in your package json.
Install
npm install ts-powertypesUsage
import type { Flatten } from 'ts-powertypes';
type Book = {
title: string;
chapters: {
title: string;
content: Record<string, string>;
}[];
};
type FlatBook = Flatten<Book>;
/*
{
title: string;
[x: `chapters.${number}.title`]: string;
[x: `chapters.${number}.content.${string}]: string;
}
*/Api
Object types
Primitiveunion of all primitive typescript typesKeyunion of primitive types that can be used as object keysElementTypegets the type of the elements of an Array, Map or RecordKeyOfunion of the keys of an objectValueOfunion of the value types of an objectObjectKeysstrong type for the return type ofObject.keys()ObjectValuesstrong type for the return type ofObject.values()ObjectEntriesstrong type for the return type ofObject.entries()Splitsplits a string constant on a given separatorJoinjoins a string constant on a given separatorFlattenflattens an object structureObjectPathsunion of all key paths of an objectValuesAtPathvalue type of an object at a given patchIsAnyevaluates totrueif the given type isany, elsefalse
Version history
See changelog