@lindeneg/types
TypeScript icon, indicating that this package has built-in type declarations

1.1.6 • Public • Published

@lindeneg/types

typescript license

Utility types.

Installation

yarn add -D @lindeneg/types

Usage

We'll use the this User type in the following examples:

type User = {
  id: number;
  name: {
    first: string;
    last: string;
  };
  address: {
    street: string;
    city: string;
  };
};

RecursivePartialObj

Partial but recursive.

import type { RecursivePartialObj } from '@lindeneg/types';

type PartialUser = RecursivePartialObj<User>;
// becomes:
{
  id?: number;
  name?: {
    first?: string;
    last?: string;
  };
  address?: {
    street?: string;
    city?: string;
  };
};

Substitute

Substitute types in an object.

import type { Substitute } from '@lindeneg/types';

type SubstitutedUser = Substitute<User, { name: [string, string] }>;
// becomes:
{
  id: number;
  name: [string, string];
  address: {
    street: string;
    city: string;
  }
}

UniqueArray

Substitute a keys type in an object with another type.

import type { UniqueArray } from '@lindeneg/types';

type Arr = UniqueArray<[1, 1, 2, 3, 4, 4, 5, 5, 5, 6, 7]>;

// becomes:
[1, 2, 3, 4, 5, 6, 7];

SafeOmit

Omit but with enhanced type-safety.

import type { SafeOmit } from '@lindeneg/types';

type OmittedUser = SafeOmit<User, 'name' | 'address'>;

// becomes:
{
  id: string;
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.6
    0
    • latest

Version History

Package Sidebar

Install

npm i @lindeneg/types

Weekly Downloads

0

Version

1.1.6

License

MIT

Unpacked Size

4.36 kB

Total Files

4

Last publish

Collaborators

  • christianlindeneg