Type-Level Testing
Utilities for type-level testing and assertions in TypeScript. These types help compare, validate, and ensure type conditions in testing or advanced development scenarios.
Type-Level Testing
Utilities for type-level testing and assertions in TypeScript. These types help compare, validate, and ensure type conditions in testing or advanced development scenarios.
Testing Types
These utilities are designed for compile-time type testing and assertions. They help ensure your utility types work correctly.
Installation
npm i -D @halvaradop/ts-utility-types
Usage
import type { Equals, Expect, Not } from "@halvaradop/ts-utility-types/test"
import type * as Test from "@halvaradop/ts-utility-types/test"
type Utilities = Test.- Equals
- Expect
- Not
Testing Utilities
Equals<X, Y>
Checks if two types are strictly equal.
Argument | Type | Description |
---|---|---|
X | any | The first type to compare. |
Y | any | The second type to compare. |
import type { Equals } from "@halvaradop/ts-utility-types/test"
type CheckTrue = Equals<true, true>
type CheckFalse = Equals<() => {}, true>
Expect<T, true>
Ensures the received type is true
. Useful for type-level tests.
Argument | Type | Description |
---|---|---|
T | true | The type to assert as true. |
import type { Expect } from "@halvaradop/ts-utility-types/test"
type CheckTrue = Expect<true>
type CheckFalse = Expect<false>
Not<T, boolean>
Negates a boolean type value.
Argument | Type | Description |
---|---|---|
T | boolean | The boolean type to negate. |
import type { Not } from "@halvaradop/ts-utility-types/test"
type CheckFalse = Not<true>
type CheckTrue = Not<false>
Runtime Validation
Helpers and type guards for runtime value validation in TypeScript and JavaScript. These functions check if a value is primitive, nullish, boolean, string, number, object, array, function, or falsy.
General Utils
General utilities and helpers for composing, manipulating, and validating types in TypeScript. Includes helpers for improving readability, creating literal unions, excluding types, working with primitive values, and more.