Mapped Types
Mapped Types Utilities for TypeScript Projects
- Thoroughly tested for type correctness
- No third-party dependencies
- Semantic Versioning
- Output separate bundles for different workflow needs (es5-commonjs, es5-module, jsnext)
Table of Contents
Mapped Types
Type Utils
Redux Typesafe Actions
DEPRECATION WARNING: this part will be removed in next major release, please use
typesafe-actions
directly instead!
typesafe-actions
Reimported from
Archived docs:
Mapped Types
DiffKeys
DiffKeys<K extends string, L extends string>
Compare set of keysK
andL
and return a subset with a difference
Usage:
; ;// Expect: 'b' | 'c'
OmitKeys
OmitKeys<K extends string, K2 extends K>
From set of keysK
subtract it's subsetK2
Usage:
; ;// Expect: 'b' | 'c'
Diff
Diff<T extends object, U extends object>
FromT
remove intersecting properties withU
Usage:
; ;// Expect { b?: number | undefined, c: boolean }
Omit
Omit<T extends object, K extends keyof T>
FromT
remove a set of propertiesK
Usage:
; ;// Expect: { b?: number | undefined, c: boolean }
Overwrite
Overwrite<T extends object, U extends object>
Replace intersecting properties fromU
toT
Usage:
; ;// Expect: { a: number, b?: number | undefined, c: boolean }
Assign
Assign<T extends object, U extends object>
Copy and replace all properties fromU
toT
Usage:
; ;// Expect: { a: number, b?: number | undefined, c: boolean, d: number }
Type Utils
getReturnOfExpression
Get return value of an "expression" with inferred return type
Alias:returntypeof
https://github.com/Microsoft/TypeScript/issues/6606
// this polyfill exist because TypeScript does not support getting type of expression // (tracking issue: https://github.com/Microsoft/TypeScript/issues/6606); // Example:; ; ;; // { type: "INCREMENT"; }
MIT License
Copyright (c) 2016 Piotr Witek piotrek.witek@gmail.com (http://piotrwitek.github.io)