
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
@deessejs/type-testing
Advanced tools
![]()
A micro library for compile-time type testing in TypeScript.
npm install @deessejs/type-testing
Or with pnpm:
pnpm add @deessejs/type-testing
Or with yarn:
yarn add @deessejs/type-testing
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()
import { Equal, NotEqual, SimpleEqual } from '@deessejs/type-testing'
// Strict equality (handles any, never, etc.)
Equal<string, string> // true
Equal<string, number> // false
// Inequality check
NotEqual<string, number> // true
// Simple equality (for plain objects)
SimpleEqual<{ a: string }, { a: string }> // true
import {
IsAny,
IsNever,
IsUnknown,
IsVoid,
IsUndefined,
IsNull,
IsNullable,
IsOptional
} from '@deessejs/type-testing'
IsAny<any> // true
IsNever<never> // true
IsUnknown<unknown> // true
IsVoid<void> // true
IsUndefined<undefined> // true
IsNull<null> // true
// Nullable = null | undefined
IsNullable<string | null> // true
IsNullable<string | undefined> // true
// Optional = may include undefined
IsOptional<string | undefined> // true
import { IsUnion, IsTuple, IsArray } from '@deessejs/type-testing'
// Unions
IsUnion<'a' | 'b'> // true
IsUnion<'a'> // false
// Tuples (fixed-length arrays)
IsTuple<[string, number]> // true
IsTuple<[]> // true
IsTuple<string[]> // false
// Arrays (dynamic-length)
IsArray<string[]> // true
IsArray<[string]> // false
import { IsInhabited, IsUninhabited } from '@deessejs/type-testing'
// Has at least one value
IsInhabited<string> // true
IsInhabited<never> // false
// Has no values (never)
IsUninhabited<never> // true
IsUninhabited<string> // false
import { HasProperty, PropertyType } from '@deessejs/type-testing'
// Check if type has a property
HasProperty<{ a: string }, 'a'> // true
HasProperty<{ a: string }, 'b'> // false
// Get property type
PropertyType<{ a: string }, 'a'> // string
import { Parameters, ReturnType, Parameter } from '@deessejs/type-testing'
// Get parameters as tuple
Parameters<(a: string, b: number) => void> // [string, number]
// Get return type
ReturnType<(a: string) => number> // number
// Get parameter at index
Parameter<(a: string, b: number), 0> // string
Parameter<(a: string, b: number), 1> // number
import { Length } from '@deessejs/type-testing'
Length<['a', 'b', 'c']> // 3
Length<[]> // 0
The library also provides runtime type checking utilities:
import {
// Type check functions returning TypeCheckResult objects
isString,
isNumber,
isBoolean,
isObject,
isArray,
isNull,
isUndefined,
// Boolean type guards (for use in conditionals)
isStringGuard,
isNumberGuard,
isBooleanGuard,
isObjectGuard,
isArrayGuard,
isNullGuard,
isUndefinedGuard,
isSymbolGuard,
isBigIntGuard,
isFunctionGuard
} from '@deessejs/type-testing'
// TypeCheckResult objects
const stringResult = isString('hello')
stringResult.matches // true
stringResult.value // 'hello'
stringResult.typeName // 'string'
// Boolean type guards
if (isStringGuard(value)) {
// value is narrowed to string here
}
import { check } from '@deessejs/type-testing'
// Type equality
check<string>().equals<string>() // passes
check<string>().equals<number>() // fails at compile time
// Type extends
check<string>().extends<string>() // passes
check<string>().extends<any>() // passes
// Property check
check<{ a: string }>().hasProperty('a') // passes
check<{ a: string }>().hasProperty('b') // fails
// Special types
check<any>().isAny() // passes
check<never>().isNever() // passes
check<unknown>().isUnknown() // passes
// Nullable/Optional
check<string | null>().isNullable() // passes
check<string | undefined>().isOptional() // passes
// Union/Tuple/Array
check<'a' | 'b'>().isUnion() // passes
check<[string, number]>().isTuple() // passes
check<string[]>().isArray() // passes
Similar to check() but throws at compile time on failure with a clearer error message.
import { assert } from '@deessejs/type-testing'
// Fails with a clear error message
assert<string>().equals<number>() // compile error
assert<{ a: string }>().hasProperty('b') // compile error
import { expect } from '@deessejs/type-testing'
// Compare two types
expect<string, string>().toBeEqual() // passes
expect<string, number>().toBeNotEqual() // passes
// Type extends
expect<string>().toExtend<string>() // passes
// Special types
expect<any>().toBeAny() // passes
expect<never>().toBeNever() // passes
// Nullable/Optional
expect<string | null>().toBeNullable() // passes
expect<string | undefined>().toBeOptional() // passes
import { ExpectTrue, ExpectEqual } from '@deessejs/type-testing'
// Assert a type is true
type Test1 = ExpectTrue<true> // true
// Assert equality - throws if not equal
type Test2 = ExpectEqual<string, string> // string
// Using with type tests
type IsString<T> = ExpectEqual<T, string>
type Result = IsString<string> // string (passes)
import { expectFalse } from '@deessejs/type-testing'
// Assert T is false at compile time
expectFalse<false>() // passes
expectFalse<true>() // compile error
| Type | Description |
|---|---|
Equal<T, U> | Strict equality check |
NotEqual<T, U> | Inequality check |
SimpleEqual<T, U> | Simple equality for plain types |
IsAny<T> | Check if type is any |
IsNever<T> | Check if type is never |
IsUnknown<T> | Check if type is unknown |
IsVoid<T> | Check if type is void |
IsUndefined<T> | Check if type is undefined |
IsNull<T> | Check if type is null |
IsNullable<T> | Check if type is null | undefined |
IsOptional<T> | Check if type may be 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 |
IsInhabited<T> | Check if type has at least one value |
IsUninhabited<T> | Check if type has no values |
HasProperty<T, K> | Check if type has property K |
PropertyType<T, K> | Get type of property K |
Parameters<T> | Get function parameters as tuple |
ReturnType<T> | Get function return type |
Parameter<T, N> | Get parameter at index N |
Length<T> | Get tuple/array length |
ExpectTrue<T> | Assert T is true |
ExpectEqual<T, U> | Assert T equals U |
| 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 |
expectFalse<T>() | Assert T is false at compile time |
MIT
FAQs
A micro library for compile-time type testing in TypeScript
The npm package @deessejs/type-testing receives a total of 27 weekly downloads. As such, @deessejs/type-testing popularity was classified as not popular.
We found that @deessejs/type-testing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.