ts-refinement
v0.2.0
Published
JavaScript-predicate refinement types for TypeScript
Downloads
369
Maintainers
Readme
ts-refinement
The type-level API for JavaScript-predicate refinement types in TypeScript.
npm install ts-refinementimport type { Refined } from "ts-refinement";
type Positive = Refined<number, "n > 0">;ts-refinement is declaration-only: it has no runtime entry point or dependencies. Bare TypeScript carries its brands but cannot prove predicate implication.
Use tspc with @ts-refinement/typescript-plugin for TypeScript 5.7 through 6.x checking, or ttsc with @ts-refinement/ttsc for TypeScript 7 and newer. @ts-refinement/cli provides publish verification, and a supported @ts-refinement/unplugin adapter inserts runtime checks for unknown assertion sites on the legacy compiler path.
See the repository README for setup, behavior, and predicate rules.
