Developer Tools

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  from "@halvaradop/ts-utility-types/test"


type  = .
  • Equals
  • Expect
  • Not

Testing Utilities

Equals<X, Y>

Checks if two types are strictly equal.

ArgumentTypeDescription
XanyThe first type to compare.
YanyThe second type to compare.
import type {  } from "@halvaradop/ts-utility-types/test"

type CheckTrue = <true, true>
type CheckTrue = true
type CheckFalse = <() => {}, true>
type CheckFalse = false

Expect<T, true>

Ensures the received type is true. Useful for type-level tests.

ArgumentTypeDescription
TtrueThe type to assert as true.
import type {  } from "@halvaradop/ts-utility-types/test"

type  = <true>


type  = <false>
Type 'false' does not satisfy the constraint 'true'.

Not<T, boolean>

Negates a boolean type value.

ArgumentTypeDescription
TbooleanThe boolean type to negate.
import type {  } from "@halvaradop/ts-utility-types/test"

type CheckFalse = <true>
type CheckFalse = false
type CheckTrue = <false>
type CheckTrue = true