ts-toolbelt vs ts-essentials vs tsdef
TypeScript Utility Libraries Comparison
1 Year
ts-toolbeltts-essentialstsdef
What's TypeScript Utility Libraries?

TypeScript utility libraries provide developers with a set of tools and types that enhance the TypeScript experience, making it easier to work with complex types, improve code quality, and streamline development processes. These libraries often include utility types, type-safe functions, and advanced type manipulation capabilities, which can significantly reduce boilerplate code and improve type safety in TypeScript projects.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
ts-toolbelt4,131,7907,002-724 years agoApache-2.0
ts-essentials3,333,4953,953243 kB22a month agoMIT
tsdef35,14359847 kB19-MIT
Feature Comparison: ts-toolbelt vs ts-essentials vs tsdef

Type Utilities

  • ts-toolbelt:

    ts-toolbelt provides an extensive collection of advanced utility types that allow for complex type manipulations, such as deep merging, conditional types, and tuple manipulations. This library is aimed at developers who need powerful tools to work with intricate type scenarios.

  • ts-essentials:

    ts-essentials offers a variety of utility types that simplify common TypeScript tasks, such as creating optional properties, extracting types from objects, and more. This library is designed to enhance the developer experience by providing easy-to-use utilities that reduce boilerplate code.

  • tsdef:

    tsdef focuses on defining types and ensuring type safety through validation. It provides utilities for creating and managing types in a way that emphasizes clarity and correctness, making it easier to maintain type integrity throughout the codebase.

Learning Curve

  • ts-toolbelt:

    ts-toolbelt has a steeper learning curve due to its advanced features and complex type manipulations. It is best suited for experienced TypeScript developers who are comfortable with the intricacies of the type system and want to leverage its full capabilities.

  • ts-essentials:

    ts-essentials is designed to be user-friendly, making it accessible for developers of all skill levels. Its straightforward API and clear documentation help users quickly understand how to implement the utilities in their projects.

  • tsdef:

    tsdef is relatively easy to learn, especially for developers familiar with TypeScript's type system. Its focus on type definitions and validation makes it intuitive for those who prioritize type safety in their projects.

Extensibility

  • ts-toolbelt:

    ts-toolbelt is highly extensible and encourages developers to build upon its advanced type utilities. Its modular design allows for easy integration of custom types and utilities, making it suitable for large-scale applications with diverse type requirements.

  • ts-essentials:

    ts-essentials is designed to be easily extensible, allowing developers to create custom utility types or functions as needed. This flexibility makes it a good choice for projects that may require specific enhancements to the provided utilities.

  • tsdef:

    tsdef is less focused on extensibility compared to the other libraries, as it primarily serves the purpose of defining and validating types. However, it can still be integrated into larger systems where type definitions need to be managed.

Community Support

  • ts-toolbelt:

    ts-toolbelt has a strong community of advanced TypeScript users and contributors. Its extensive documentation and examples provide valuable resources for developers looking to utilize its advanced features effectively.

  • ts-essentials:

    ts-essentials has a growing community and is well-documented, which helps developers find support and resources easily. Its popularity is increasing, making it a reliable choice for TypeScript projects.

  • tsdef:

    tsdef has a smaller community compared to the other two packages, but it is well-maintained and offers sufficient documentation to assist users. It is particularly useful for niche applications that require strict type definitions.

Performance

  • ts-toolbelt:

    ts-toolbelt, while powerful, can introduce complexity that may affect performance in certain scenarios, especially with deeply nested types. Developers should be mindful of performance implications when using its advanced features.

  • ts-essentials:

    ts-essentials is optimized for performance, providing lightweight utilities that do not add significant overhead to TypeScript projects. This makes it suitable for applications where performance is a key concern.

  • tsdef:

    tsdef is designed to be efficient in managing type definitions and validations, ensuring that performance remains optimal even in larger applications where type integrity is crucial.

How to Choose: ts-toolbelt vs ts-essentials vs tsdef
  • ts-toolbelt:

    Choose ts-toolbelt if you require advanced type manipulation capabilities and a rich set of utility types. It is ideal for projects that demand high flexibility and complex type operations, making it suitable for experienced TypeScript developers who want to leverage the full power of TypeScript's type system.

  • ts-essentials:

    Choose ts-essentials if you need a library that provides a comprehensive set of utility types and functions that are easy to use and integrate into existing TypeScript projects. It is particularly useful for developers looking for a straightforward approach to enhancing type safety and code quality without a steep learning curve.

  • tsdef:

    Choose tsdef if you are looking for a library focused on defining and validating TypeScript types in a more structured way. It is particularly useful for projects that require strict type definitions and validation, making it a good fit for applications where type integrity is critical.

README for ts-toolbelt

banner

TypeScript's largest utility library

Language grade: JavaScript

📖 Documentation · 📣 Announcements · 🐞 Report Bug · 🍩 Request Feature · 🤔 Ask Questions

About

ts-toolbelt is the largest, and most tested type library available right now, featuring +200 utilities. Our type collection packages some of the most advanced mapped types, conditional types, and recursive types on the market.

Spend less time, build stronger. Benefit from a wide range of generic type functions to achieve better type safety.

We work just like lodash, or ramda, but applied to the type system. Our mission is to provide you with simple ways to compute, change, and create types. We abstract all those complex type checks away for you. We provide a simple, reusable, and standard API to help you get more done with TypeScript.

ts-toolbelt is a well organized package that can help you perform advanced operations on object types, union types, as well as function, and literal types. It is carefully and coherently designed for building robust, flexible, and type-safe software.

demo

We are a community and a knowledge base. Everyone is welcome to ask questions about types. If you are stuck or you misunderstand something, you came to the right place!. We welcome beginners and advanced developers to come take part. Welcome!

Getting Started

Prerequisites

npm install typescript@^4.1.0 --save-dev

For best results, add this to your tsconfig.json

{
  "compilerOptions": {
    // highly recommended (required by few utilities)
    "strictNullChecks": true,

    // this is optional, but enable whenever possible
    "strict": true,

    // this is the lowest supported standard library
    "lib": ["es2015"],
  }
}

Installation

npm install ts-toolbelt --save

Hello World

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

// Merge two `object` together
type merge = Object.Merge<{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}

You can level-up, and re-code this library from scratch.

Documentation ⤢

Imports

The project is organized around TypeScript's main concepts:

| Any | Boolean | Class | Function | Iteration | List | |------------|-------------|--------------|--------------|---------------|----------| | Number | Object | Object.P | String | Union | Test |

TIP How to choose categories? Match your type with them.

There are many ways to import the types into your project:

  • Explicit

    import {Any, Boolean, Class, Function, Iteration, List, Number, Object, String, Union} from "ts-toolbelt"
    
  • Compact

    import {A, B, C, F, I, L, N, O, S, U} from "ts-toolbelt"
    
  • Portable

    import tb from "ts-toolbelt"
    

You can also import our non-official API from the community:

import {Community} from "ts-toolbelt"

TIP The community API is for our community to publish useful types that don't see fit in the standard API.

Utility Index

|ANY|OBJECT|LIST|FUNCTION|STRING|UNION|CLASS|BOOLEAN|NUMBER|OBJECT.P|ITERATION| |---|---|---|---|---|---|---|---|---|---|---| |Await|Assign|Append|AutoPath|At|Diff|Class|And|Absolute|Merge|Iteration| |At|AtLeast|Assign|Compose|Join|Exclude|Instance|Not|Add|Omit|IterationOf| |Cast|Compulsory|AtLeast|Curry|Length|Filter|Parameters|Or|Greater|Pick|Key| |Compute|CompulsoryKeys|Compulsory|Exact|Replace|Has||Xor|GreaterEq|Readonly|Next| |Contains|Diff|CompulsoryKeys|Function|Split|IntersectOf|||IsNegative|Update|Pos| |Equals|Either|Concat|Length||Last|||IsPositive|Record|Prev| |Extends|Exclude|Diff|Narrow||Merge|||IsZero||| |Key|ExcludeKeys|Drop|NoInfer||NonNullable|||Lower||| |Keys|Filter|Either|Parameters||Nullable|||LowerEq||| |KnownKeys|FilterKeys|Exclude|Pipe||Pop|||Negate||| |Is|Has|ExcludeKeys|Promisify||Replace|||Range||| |Promise|HasPath|Extract|Return||Select|||Sub||| |Try|Includes|Filter|UnCurry||Strict|||||| |Type|Intersect|FilterKeys|ValidPath||ListOf|||||| |x|IntersectKeys|Flatten||||||||| ||Invert|Group||||||||| ||ListOf|Has||||||||| ||Merge|HasPath||||||||| ||MergeAll|Head||||||||| ||Modify|Includes||||||||| ||NonNullable|Intersect||||||||| ||NonNullableKeys|IntersectKeys||||||||| ||Nullable|KeySet||||||||| ||NullableKeys|Last||||||||| ||Object|LastKey||||||||| ||Omit|Length||||||||| ||Optional|List||||||||| ||OptionalKeys|Longest||||||||| ||Overwrite|Merge||||||||| ||Partial|MergeAll||||||||| ||Patch|Modify||||||||| ||PatchAll|NonNullable||||||||| ||Path|NonNullableKeys||||||||| ||Paths|Nullable||||||||| ||Pick|NullableKeys||||||||| ||Readonly|ObjectOf||||||||| ||ReadonlyKeys|Omit||||||||| ||Record|Optional||||||||| ||Replace|OptionalKeys||||||||| ||Required|Overwrite||||||||| ||RequiredKeys|Partial||||||||| ||Select|Patch||||||||| ||SelectKeys|PatchAll||||||||| ||Undefinable|Path||||||||| ||UndefinableKeys|Paths||||||||| ||Unionize|Pick||||||||| ||UnionOf|Pop||||||||| ||Update|Prepend||||||||| ||Writable|Readonly||||||||| ||WritableKeys|ReadonlyKeys||||||||| |||Remove||||||||| |||Repeat||||||||| |||Replace||||||||| |||Required||||||||| |||RequiredKeys||||||||| |||Reverse||||||||| |||Select||||||||| |||SelectKeys||||||||| |||Shortest||||||||| |||Tail||||||||| |||Take||||||||| |||Undefinable||||||||| |||UndefinableKeys||||||||| |||Unionize||||||||| |||UnionOf||||||||| |||UnNest||||||||| |||Update||||||||| |||Writable||||||||| |||WritableKeys||||||||| |||Zip||||||||| |||ZipObj|||||||||

Archives ⤢

EXAMPLE https://millsp.github.io/ts-toolbelt/4.2.1/

Good to Know ⤢

In this wiki, you will find some extra resources for your learning, and understanding.

Are you missing something? Participate to the open-wiki by posting your questions.

Running tests

For this project

To run the lint & type tests, simply run:

npm test

For your project

Want to test your own types? Let's get started:

import {Number, Test} from "ts-toolbelt"

const {checks, check} = Test

checks([
    check<Number.Add<1, 30>, 31, Test.Pass>(),
    check<Number.Add<5, -3>, 2,  Test.Pass>(),
])

TIP Place it in a file that won't be executed, it's just for TypeScript to test types.

Continuous Integration

The releases are done with Travis CI in stages & whenever a branch or PR is pushed:

  • Tests are run with npm test
  • Tests against DefinitelyTyped
  • Releases to npm@[branch-name]

Compatibility

The project is maintained to adapt to the constant changes of TypeScript:

| ts-toolbelt | typescript | |-------------|------------| | 9.x.x | ^4.1.x |

Major version numbers will upgrade whenever TypeScript had breaking changes.

Otherwise, the release versions will naturally follow the semantic versioning.

What's next

  • Automated performance tests

    # performance is checked manually with 
    npx tsc --noEmit --extendedDiagnostics
    
  • Need to write more examples

Related Projects

| Name | Intro | |----------------------------------------------------------------|------------------------------------------------------------------------------------------| | eledoc | 🌒 A material dark theme for TypeDoc. | | material-candy | 🍬 A vscode theme to uplift your mood, stay happy and focused. | | utility-types | Collection of utility types, complementing TypeScript built-in mapped types and aliases. |

License

FOSSA
Status