The ts-advanced-types library is a collection of utility types designed to simplify and enhance TypeScript development. I started it four years ago to address common challenges such as excluding specific properties from objects, enforcing mutually exclusive type options, and defining tree-like data models, making your code more expressive and maintainable.
Built to streamline everyday TypeScript tasks, this library consolidates frequently used advanced types into a reusable package. By sharing these tools with the community, my goal is to help developers write cleaner, more reliable code and save time across projects.
Setting up the ts-advanced-types library is straightforward. Since the project is not transpiled, it directly exposes all types and utilities through its index.ts file. This ensures a lightweight and hassle-free integration into your TypeScript project.
1 Add the library to your project via npm or yarn:
npm installts-advanced-types
# or
yarn add ts-advanced-types
2 Import the required types or utilities directly from the package:
import { TypeXOR, Without } from 'ts-advanced-types';
No additional configuration is needed—you’re ready to start using the library. This simplicity allows you to focus entirely on leveraging the provided tools to enhance your TypeScript workflows.
The library includes a wide range of utility types and helpers that solve common TypeScript challenges. From enforcing stricter object constraints to creating mutually exclusive type options, each utility is designed to address specific use cases while improving code clarity and maintainability. These types are all ready to use and can seamlessly integrate into your existing projects, saving you time and effort
Without<T, U> Remove all properties from T that are assignable to UTypeXOR<T, U> XOR of two typesFalsy JavaScript falsy typesPrimitiveValidIndexSignature JavaScript primitive types accepted as index signaturesPrimitive JavaScript primitive non-falsy typesComplex JavaScript non-falsy types