New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ts-powertypes

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-powertypes

Collection of typescript types

latest
Source
npmnpm
Version
0.0.5
Version published
Maintainers
1
Created
Source

author snyk downloads npm version license

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-powertypes

Usage

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

  • Primitive union of all primitive typescript types

  • Key union of primitive types that can be used as object keys

  • ElementType gets the type of the elements of an Array, Map or Record

  • KeyOf union of the keys of an object

  • ValueOf union of the value types of an object

  • ObjectKeys strong type for the return type of Object.keys()

  • ObjectValues strong type for the return type of Object.values()

  • ObjectEntries strong type for the return type of Object.entries()

  • Split splits a string constant on a given separator

  • Join joins a string constant on a given separator

  • Flatten flattens an object structure

  • ObjectPaths union of all key paths of an object

  • ValuesAtPath value type of an object at a given patch

  • IsAny evaluates to true if the given type is any, else false

Version history

See changelog

Keywords

typescript

FAQs

Package last updated on 12 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts