Skip to content

nesalia-inc/type-testing

Repository files navigation

type-testing

@deessejs/type-testing

npm Version Bundle Size Tests License

A micro library for compile-time type testing in TypeScript.

Requirements

  • TypeScript 5.0+

Installation

# Install type-testing
npm install @deessejs/type-testing

# Or using pnpm
pnpm add @deessejs/type-testing

# Or using yarn
yarn add @deessejs/type-testing

Usage

import { Equal, check, assert, expect } from '@deessejs/type-testing'

// Simple type equality
type Test = Equal<string, string>  // true

// Chainable API
check<string>().equals<string>()   // passes

// Assert with clear errors
assert<{ a: string }>().hasProperty('a')

// Expect syntax
expect<string, string>().toBeEqual()

Features

  • Type Equality - Strict and simple equality checks
  • Special Type Detection - IsAny, IsNever, IsUnknown, IsVoid, etc.
  • Union/Tuple/Array Detection - IsUnion, IsTuple, IsArray
  • Type Inhabitation - IsInhabited, IsUninhabited
  • Property Testing - HasProperty, PropertyType
  • Function Types - Parameters, ReturnType, Parameter
  • Chainable API - check(), assert(), expect() for fluent testing

API Reference

Types

Type Description
Equal<T, U> Strict equality check
NotEqual<T, U> Inequality check
IsAny<T> Check if type is any
IsNever<T> Check if type is never
IsUnknown<T> Check if type is unknown
IsNullable<T> Check if type is null | undefined
IsUnion<T> Check if type is a union
IsTuple<T> Check if type is a tuple
IsArray<T> Check if type is an array

Functions

Function Description
check<T>() Create a chainable type checker
assert<T>() Create an assert type checker (throws on failure)
expect<T, U>() Create an expect-style type checker

For complete documentation, see packages/type-testing/README.md

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

  • Nesalia Inc.

Security

If you discover any security vulnerabilities, please send an e-mail to security@nesalia.com.

License

MIT License - see the LICENSE file for details.

About

A micro library for compile-time type testing in TypeScript

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •