Must-have utility types and functions for TypeScript
This is a small util library which contains several types and functions that may be useful in your TypeScript project.
npm install typescript-essentials
yarn add typescript-essentials
Useful to compose simple predicates, or to narrow types in arrays or other data structures.
Predicate
andTypeGuard
interfacesnot()
function to negate predicatesmatchesDiscriminator()
function that returns a type guardisNull()
type guardisUndefined()
type guardisNullOrUndefined()
type guardisNotNull()
type guardisNotUndefined()
type guardisNotNullOrUndefined()
type guard
DiscriminatedUnion
to narrow a union type using a discriminator fieldNarrowable
to identify a type that can be narrowedSubtract
to subtract types from one anotherWithOptional
to make certain properties optional
Thanks goes to these wonderful people (emoji key):
Dirk Luijk 💻 📖 |
Daan Scheerens 🤔 |
This project follows the all-contributors specification. Contributions of any kind welcome!