DEV Community

Pierre-Antoine Mills
Pierre-Antoine Mills

Posted on

πŸ‘· Higher type safety for TypeScript


πŸ’£ The problem

Have you ever found yourself needing to change an external type from another library, or just needing specific fields to become optional?

Or maybe you just wanted to update a type, but deeply?

Or even just simply concat to tuples together into one?

A week ago, this was not possible... Until today.

πŸ€” But how?

What if I told you that most of the pain of TypeScript could be put away forever?
So that you can focus on what matters now, not working around TS' limitations??

These are just a few examples for the most common type manipulations.

🍩 So what is it?

I am proud to annouce ts-toolbelt. A 100% tested type library that makes coding with TypeScript even safer. But not only, it will also make your software more robust and more flexible.

It uses the type system itself for TypeScript to compute more complex types. In other words, its API exposes types that trade CPU & RAM for higher type safety.

ts-toolbelt completes TypeScript with a collection of more than 150 tested types. It's goal is to improve type correctness while adding a whole new set of features to TS.

πŸ₯… Goals

  • This package aims to be the home of all utility types
  • Keep reasonable performance, so it will not bloat TS
  • Computed types are always readable, like if you typed it
  • Software that's more type-safe, flexible & more robust
  • Bring a whole new set of extra features to TypeScript
  • Types can be combined together to create even more types!

🏁 Getting Started


npm install typescript@^3.5.0 --save


npm install ts-toolbelt --save

Hello World

import {Object} from 'ts-toolbelt'

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

The project is huge but very well documented with a website (and a search bar). So if you're ready to be type-safe, here's my repository.

This is my first open-source project, your comments are more than welcome πŸ˜‰

Top comments (3)

epolanski profile image
Enrico Polanski

Found this library and this post after finding your post about your curry implementation on FreeCodeCamp.

Wanted to congratulate you for this very fine work and your written content.

pirixgh profile image
Pierre-Antoine Mills


risingbirdsong profile image

Hi Pierre, like Enrico i've been following you since your awesome typing Ramda article on Free Code Camp.

I hope you're doing well!