Skip to content

v1.2 • Dev Tools • 4kb gzipped • MIT

TypeGuardian

Runtime validation that infers its static types, so a schema is written exactly once.

★ 6.8kGitHub
↓ 22.6k / week● MIT● TS 5.0+
typeguardian-preview.png
Abstract preview graphic for TypeGuardian

// why typeguardian

One source of truth

Write the runtime schema and the static type is inferred from it. The two can never drift because there is only one.

● 0 deps● 14ms cold start● CI ready

// stack

Errors people can read

Failures report the path, the expected shape and the value that arrived, not a stack trace.

TypeGuardian started as a single file in a client project and stayed small on purpose. It does one job, it does it in 4kb gzipped, and it has no runtime dependencies.

Getting started

Install it, import it, call it:

npm i typeguardian-js

Write the runtime schema and the static type is inferred from it. The two can never drift because there is only one.

What it does not do

It does not manage your state, style your components or ship a plugin system. Those are your decisions, and keeping them out is what keeps the bundle honest.

  • Inferred static types
  • Path-accurate errors
  • MIT licensed, commercially friendly

Features

Inferred static types

No duplicate interface to maintain beside the validator.

Path-accurate errors

Nested failures report the exact key path that failed.

Readable reports

Terminal output for humans, JSON for everything else.

ESM and types

Ships module and CommonJS builds with hand-written type definitions and source maps.

CI first

Exits with a meaningful status code and prints machine-readable output on request.

Config optional

Sensible defaults mean TypeGuardian does something useful before you configure anything.

Get TypeGuardian v1.2

7 files • .min.js 4kb • .zip 55kb • sha384 verified

Changelog

v1.2 Nov 17 2025 • latest
  • Discriminated union support
  • Path-accurate error messages
  • Async refinement functions
v1.1.1 Sep 15 2025
  • Fixed a memory leak on repeated teardown
  • Source maps now published with every build
v1.1 Jul 3 2025
  • Type definitions rewritten by hand
  • Dropped the last runtime dependency
View full archive →

// related

Related products

Sep 10 • v2.0

ChartForge

Canvas charts in twelve lines. Responsive, accessible and dark-mode ready, with no D3 learning curve.

View →
Aug 30 • v3.2.1

MotionEase

Physics-based micro-animations with a single call. Spring curves that feel right without a tuning session.

View →
Aug 19 • v1.9.4

FormFlow

Validation and multi-step logic that works the same in React, Vue and vanilla. Your markup stays yours.

View →

Wire it into CI today.

MIT licensed. Commercial friendly. Five-minute setup.