typescript-miscellaneous
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

TypeScript Miscellaneous

Requirements

  • TypeScript ≥ 3.0.0

Usage

Dict

Without TypeScript Miscellaneous:

type MyObj = {
  a: number
  b: number
  c: number
  0: number
  1: number
}

With TypeScript Miscellaneous:

import { Dict } from 'typescript-miscellaneous'
 
type MyObj = Dict<
  'a' | 'b' | 'c' | 0 | 1,
  number
>

UnionToIntersection

import { UnionToIntersection } from 'typescript-miscellaneous'
type Intersection = UnionToIntersection<0 | 1 | 2> // Expect: 0 & 1 & 2

ElementOf

import { ElementOf } from 'typescript-miscellaneous'
type Element = ElementOf<[0, 1, 2, 3]> // Expect: 0 | 1 | 2 | 3

ParametersOf

import { ParametersOf } from 'typescript-miscellaneous'
type Parameters = ParametersOf<(a: 0, b: 1) => void> // Expect: [0, 1]

ReturnOf

import { ReturnOf } from 'typescript-miscellaneous'
type Return = ReturnOf<() => 123> // Expect: 123

License

MIT © Hoàng Văn Khải

Package Sidebar

Install

npm i typescript-miscellaneous

Weekly Downloads

1,125

Version

0.1.1

License

MIT

Unpacked Size

7.25 kB

Total Files

35

Last publish

Collaborators

  • khai96_