BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News ts-toolbelt Adds over 200 Type Utilities to TypeScript

ts-toolbelt Adds over 200 Type Utilities to TypeScript

This item in japanese

Bookmarks

ts-toolbelt provides a type library to update, change, and compute TypeScript types.

Through a lodash-inspired programmatic API, ts-toolbelt provides more than 200 type utilities while adding minimal overhead to TypeScript.

ts-toolbelt leverages the TypeScript type system for computing complex types. The ts-toolbelt project strives to offer many examples for solving common challenges in TypeScript, encourage type evolution and reusability, and help developers more easily create flexible, type-safe code.

The ts-toolbelt project touts its support for many features, including merging types, concatenating lists, and a variety of additional types on objects, lists, and functions. ts-toolbelt encourages the use of strict type checking and strict null checks.

Installation of ts-toolbelt occurs via npm:

npm install ts-toolbelt --save

The project provides a simple Hello World example for getting started with ts-toolbelt:

import {Object} from 'ts-toolbelt'
// Check the docs below for more

// Merge two `object` together
type merge = Object.MergeUp<{name: string}, {age?: number}>
// {name: string, age?: number}

// Make a field of an `object` optional
type optional = Object.Optional<{id: number, name: string}, 'name'}>
// {id: number, name?: string}

Community reaction to ts-toolbelt is generally very positive. Each major release of ts-toolbelt gets updated to support changes in the quarterly releases of TypeScript.

ts-toolbelt is open-source software available under the Apache 2 license. Contributions are welcome via the ts-toolbelt GitHut repository following the contribution guidelines and code of conduct. Enterprises can also support ts-toolbelt via Tidelift.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT