Skip to main content
@gentleduck/ttest

Test your types with tsc

Compile-time type tests and more than 200 utility types for TypeScript. No test runner and no runtime cost.

  • AssertTrue and AssertFalse

    Boolean assertions at compile time, with custom messages. A failing test shows up as a red underline in your editor.

  • Expect<Equal>

    Structural equality for types. It catches widening, distributive drift, and excess-property regressions.

  • 200+ utility types

    Primitives, predicates, strings, tuples, objects, numbers, unions, and brands, each imported from its own subpath.

  • Zero runtime

    The .js files are empty on purpose. Every utility disappears at build time, so your bundle stays the same.

  • Subpath imports

    Import @gentleduck/ttest/string or /tuple. Each domain has its own entry, so you only load what you use.

  • No test runner

    No Jest and no Vitest. tsc --noEmit runs your tests in any project, editor, or CI.

Install

Install it as a dev dependency, write tests in .test-d.ts files, and let tsc run them.

  1. Install

    bun add -D @gentleduck/ttest
  2. Write a type test

    import type { AssertTrue, Equal } from '@gentleduck/ttest/assert'
    
    type _test = AssertTrue<Equal<Uppercase<'gentle'>, 'GENTLE'>, 'uppercase works'>

Free & open source

gentleduck is MIT licensed and will always be free and open source. Every package ships with full source access — fork it, modify it, own it.

Become a Sponsor