nat-ts
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

nat-ts

Type-level natural numbers for Typescript.

import { Nat, Z, S, Lit } from "nat-ts";
 
type Zero = Z;
type One = S<Z>;
type Two = S<S<Z>>; // also = S<One>;
 
type AnyNat<N extends Nat> = N;
type Zero_b = AnyNat<Z>;
type One_b = AnyNat<S<Z>>;
// type Two_b = AnyNat<2>; // type error: 2 is not a Nat.
 
type Zero_c = Lit._0;
type One_c = Lit._1;
// ...
type OneHundredTwentyThree = Lit._123;
// ...
type OneThousand = Lit._1000;

Readme

Keywords

none

Package Sidebar

Install

npm i nat-ts

Weekly Downloads

1

Version

2.0.1

License

BSD-3-Clause

Unpacked Size

34 kB

Total Files

6

Last publish

Collaborators

  • thomaseding