Home

Awesome

typescript-conditional-types

npm version Conventional Commits code style: prettier

Helpers for typescript generic types

Table of Contents

Motivation

Creating complex types with conditional types ( T extends U ? X : Y ) could be a little verbose. This package aims to simplify code and make it more readable.

Install

$ npm install typescript-conditional-types

You'll probably want to save it in the devDependencies

Type Helper List

Usage Example

import { If } from "typescript-conditional-types";

type BooleanToString<T extends boolean> = If<T, "true", "false">

BooleanToString<true> // "true"
BooleanToString<false> // "false"