Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.