Home

Awesome

<p align="center"> <img src="/logo.png" width="120" alt="ts-essentials"> <h3 align="center">ts-essentials</h3> <p align="center">All essential TypeScript types in one place πŸ€™</p> <p align="center"> <a href="https://www.npmjs.com/package/ts-essentials" title="View this project on NPM"> <img alt="Version" src="https://img.shields.io/npm/v/ts-essentials.svg"> </a> <img alt="Downloads" src="https://img.shields.io/npm/dm/ts-essentials.svg"> <a href="https://github.com/ts-essentials/ts-essentials/actions?query=branch%3Amaster" title="View Github Build status"> <img alt="Build status" src="https://github.com/ts-essentials/ts-essentials/actions/workflows/ci.yml/badge.svg"> </a> <a href="https://t.me/ts_essentials" title="Get support in Telegram"> <img alt="Telegram" src="https://img.shields.io/badge/-telegram-red?color=white&logo=telegram"> </a> <a href="/package.json"><img alt="Software License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"></a> <a href="https://codechecks.io"><img src="https://raw.githubusercontent.com/codechecks/docs/master/images/badges/badge-default.svg?sanitize=true" alt="codechecks.io"></a> </p> </p>

Install

npm install --save-dev ts-essentials

πŸ‘‰ We require typescript>=4.5. If you're looking for support for older TS versions, please have a look at the TypeScript dependency table

πŸ‘‰ As we really want types to be stricter, we require enabled strictNullChecks in your project

API

ts-essentials is a set of high-quality, useful TypeScript types that make writing type-safe code easier.

Basic

Utility types

Mark wrapper types

Deep wrapper types

Key types

Type checkers

Arrays and Tuples

Change case

Function types

Utility functions

⚠️ Make sure you add ts-essentials to your dependencies (npm install --save ts-essentials) to avoid runtime errors

Search

When one of utility types is known by a different name, kindly ask adding it here for the better search.

Built-in types

TypeScript provides several utility types to facilitate common type transformations. These utilities are available globally.

TypeScript dependency table

ts-essentialstypescript / type of dependency
^10.0.0^4.5.0 / peer optional
^9.4.0^4.1.0 / peer optional
^8.0.0^4.1.0 / peer
^5.0.0^3.7.0 / peer
^3.0.1^3.5.0 / peer
^1.0.1^3.2.2 / dev
^1.0.0^3.0.3 / dev

Contributors

Thanks goes to these wonderful people (emoji key):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tr> <td align="center"><a href="https://twitter.com/krzkaczor"><img src="https://avatars2.githubusercontent.com/u/1814312?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chris Kaczor</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=krzkaczor" title="Code">πŸ’»</a> <a href="#business-krzkaczor" title="Business development">πŸ’Ό</a> <a href="#example-krzkaczor" title="Examples">πŸ’‘</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=krzkaczor" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://scholar.google.com/citations?user=3xZtvpAAAAAJ"><img src="https://avatars3.githubusercontent.com/u/9780746?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Xiao Liang</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=yxliang01" title="Code">πŸ’»</a> <a href="#ideas-yxliang01" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=yxliang01" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://github.com/Andarist"><img src="https://avatars2.githubusercontent.com/u/9800850?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mateusz BurzyΕ„ski</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=Andarist" title="Code">πŸ’»</a> <a href="#ideas-Andarist" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=Andarist" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://github.com/macbem"><img src="https://avatars1.githubusercontent.com/u/12464061?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maciej Bembenista</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=macbem" title="Code">πŸ’»</a> <a href="#ideas-macbem" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=macbem" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://github.com/MichaelTontchev"><img src="https://avatars0.githubusercontent.com/u/12261336?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Michael Tontchev</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=MichaelTontchev" title="Code">πŸ’»</a> <a href="#ideas-MichaelTontchev" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=MichaelTontchev" title="Documentation">πŸ“–</a></td> <td align="center"><a href="http://ThomasdH.blogspot.com"><img src="https://avatars0.githubusercontent.com/u/3889750?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Thomas den Hollander</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=ThomasdenH" title="Code">πŸ’»</a> <a href="#ideas-ThomasdenH" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=ThomasdenH" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://twitter.com/esamatti"><img src="https://avatars3.githubusercontent.com/u/225712?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Esa-Matti Suuronen</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=epeli" title="Code">πŸ’»</a> <a href="#ideas-epeli" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=epeli" title="Documentation">πŸ“–</a></td> </tr> <tr> <td align="center"><a href="https://github.com/IlyaSemenov"><img src="https://avatars1.githubusercontent.com/u/128121?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ilya Semenov</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=IlyaSemenov" title="Code">πŸ’»</a> <a href="#ideas-IlyaSemenov" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=IlyaSemenov" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://codechecks.io"><img src="https://avatars2.githubusercontent.com/u/46399828?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Code Checks</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/pulls?q=is%3Apr+reviewed-by%3Acodechecks" title="Reviewed Pull Requests">πŸ‘€</a></td> <td align="center"><a href="http://www.nomiclabs.io"><img src="https://avatars1.githubusercontent.com/u/176499?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Patricio Palladino</b></sub></a><br /><a href="#ideas-alcuadrado" title="Ideas, Planning, & Feedback">πŸ€”</a></td> <td align="center"><a href="http://twitter.com/quezak2"><img src="https://avatars0.githubusercontent.com/u/666206?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Artur Kozak</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=quezak" title="Code">πŸ’»</a> <a href="#ideas-quezak" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=quezak" title="Documentation">πŸ“–</a> <a href="https://github.com/ts-essentials/ts-essentials/pulls?q=is%3Apr+reviewed-by%3Aquezak" title="Reviewed Pull Requests">πŸ‘€</a></td> <td align="center"><a href="https://github.com/lucifer1004"><img src="https://avatars2.githubusercontent.com/u/13583761?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Zihua Wu</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=lucifer1004" title="Code">πŸ’»</a> <a href="#ideas-lucifer1004" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=lucifer1004" title="Documentation">πŸ“–</a></td> <td align="center"><a href="http://kevinpeno.com"><img src="https://avatars1.githubusercontent.com/u/343808?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kevin Peno</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=kevinpeno" title="Code">πŸ’»</a></td> <td align="center"><a href="https://github.com/DomParfitt"><img src="https://avatars2.githubusercontent.com/u/11363907?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dom Parfitt</b></sub></a><br /><a href="#ideas-DomParfitt" title="Ideas, Planning, & Feedback">πŸ€”</a></td> </tr> <tr> <td align="center"><a href="https://github.com/EduardoRFS"><img src="https://avatars0.githubusercontent.com/u/3393115?v=4?s=100" width="100px;" alt=""/><br /><sub><b>EduardoRFS</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=EduardoRFS" title="Code">πŸ’»</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=EduardoRFS" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://andydvorak.net/"><img src="https://avatars1.githubusercontent.com/u/409245?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andrew C. Dvorak</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=acdvorak" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://github.com/a1russell"><img src="https://avatars0.githubusercontent.com/u/241628?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Adam Russell</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=a1russell" title="Code">πŸ’»</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=a1russell" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://github.com/sz-piotr"><img src="https://avatars2.githubusercontent.com/u/17070569?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Piotr Szlachciak</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=sz-piotr" title="Code">πŸ’»</a> <a href="#ideas-sz-piotr" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=sz-piotr" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://github.com/mikhailswift"><img src="https://avatars3.githubusercontent.com/u/3218582?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mikhail Swift</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=mikhailswift" title="Code">πŸ’»</a></td> <td align="center"><a href="https://github.com/DevilZh"><img src="https://avatars1.githubusercontent.com/u/10295215?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ryan Zhang</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=DevilZh" title="Code">πŸ’»</a> <a href="#ideas-DevilZh" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=DevilZh" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://www.linkedin.com/in/francesco-borzi/"><img src="https://avatars1.githubusercontent.com/u/75517?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Francesco BorzΓ¬</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=FrancescoBorzi" title="Documentation">πŸ“–</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=FrancescoBorzi" title="Code">πŸ’»</a></td> </tr> <tr> <td align="center"><a href="https://github.com/leaumar"><img src="https://avatars2.githubusercontent.com/u/3950300?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Marnick L'Eau</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=leaumar" title="Code">πŸ’»</a> <a href="#ideas-leaumar" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=leaumar" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://github.com/kubk"><img src="https://avatars1.githubusercontent.com/u/22447849?v=4?s=100" width="100px;" alt=""/><br /><sub><b>kubk</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=kubk" title="Code">πŸ’»</a></td> <td align="center"><a href="https://github.com/bbarry"><img src="https://avatars0.githubusercontent.com/u/84951?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bill Barry</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=bbarry" title="Code">πŸ’»</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=bbarry" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://github.com/akwodkiewicz"><img src="https://avatars2.githubusercontent.com/u/22861194?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andrzej WΓ³dkiewicz</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=akwodkiewicz" title="Code">πŸ’»</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=akwodkiewicz" title="Documentation">πŸ“–</a> <a href="#ideas-akwodkiewicz" title="Ideas, Planning, & Feedback">πŸ€”</a></td> <td align="center"><a href="http://chjdev.com"><img src="https://avatars2.githubusercontent.com/u/973941?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christian</b></sub></a><br /><a href="#ideas-chjdev" title="Ideas, Planning, & Feedback">πŸ€”</a></td> <td align="center"><a href="https://github.com/mattleff"><img src="https://avatars0.githubusercontent.com/u/120155?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Matthew Leffler</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=mattleff" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://github.com/studds"><img src="https://avatars2.githubusercontent.com/u/3046407?v=4?s=100" width="100px;" alt=""/><br /><sub><b>studds</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=studds" title="Code">πŸ’»</a></td> </tr> <tr> <td align="center"><a href="https://github.com/Beraliv"><img src="https://avatars.githubusercontent.com/u/2991847?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alex Berezin</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=Beraliv" title="Code">πŸ’»</a> <a href="https://github.com/ts-essentials/ts-essentials/commits?author=Beraliv" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://github.com/vitonsky"><img src="https://avatars.githubusercontent.com/u/86191922?v=4?s=100" width="100px;" alt=""/><br /><sub><b>vitonsky</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=vitonsky" title="Documentation">πŸ“–</a></td> <td align="center"><a href="https://github.com/itayronen"><img src="https://avatars.githubusercontent.com/u/21139000?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Itay Ronen</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=itayronen" title="Code">πŸ’»</a></td> <td align="center"><a href="https://github.com/cyberbiont"><img src="https://avatars.githubusercontent.com/u/59398323?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yaroslav Larin</b></sub></a><br /><a href="https://github.com/ts-essentials/ts-essentials/commits?author=cyberbiont" title="Code">πŸ’»</a></td> </tr> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the all-contributors specification. Contributions of any kind welcome! Read more