Last active
April 4, 2020 00:22
-
-
Save millsp/f7f7d18773f79bf0618fb5cd55bd48f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Object, Tuple, Number} from 'ts-toolbelt' | |
// Merge two types together | |
type merge = Object.MergeUp<{name: string}, {age?: number}> | |
// Update the type of a field | |
type update = Object.Update<{age: string}, 'age', number> | |
// Make some fields optional | |
type optional = Object.Optional<{name: string, age: number}, 'age'> | |
// Update a type at any depth! (`P` stands for `Path`) | |
type deepUpdate = Object.P.Update<{a: {b: {c: 1}}}, ['a', 'b', 'c'], 42> | |
// Concat two tuples together | |
type concat = Tuple.Concat<[1, 2], [3, 4]> | |
// Add two numbers together | |
type add = Number.Plus<'10', '-21'> | |
// And much more... Check the docs out! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment