ts-multipick
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

ts-multipick

Like the TypeScript Pick utility, but deeper: Pick2, Pick3, ..., Pick9.

Usage

import {Pick3} from 'ts-multipick';

type SomeShape = {
  username: string;
  address: {
    street: {
      name: string;
      city: {
        name: string;
        country: string;
      }
    }
  }
};

type ObjWithStreetName = Pick3<SomeShape, 'address', 'street', 'name'>;

let a: ObjWithStreetName = /* ... */;
a.address.street.city; // ERROR! This is a TypeScript error
a.address.street.city.name; // ERROR! This is a TypeScript error
a.username; // ERROR! This is a TypeScript error
a.address.street.name; // Only this is fine

Install

npm install --save ts-multipick

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i ts-multipick

Weekly Downloads

182

Version

1.0.0

License

MIT

Unpacked Size

10.8 kB

Total Files

9

Last publish

Collaborators

  • staltz