Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

add NumberToString conversion map #7

Merged
merged 2 commits into from
Jul 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
lib
dev
/.idea/
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export type Max<N1 extends Nat, N2 extends Nat> = If<Lte<N1, N2>, N2, N1>
*/
export type NumberToNat = TupleToObject<[_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10]>

export type NumberToString = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

/** max Nat = _10 */
export type NatToNumber<N extends Nat> = If<
NatEq<N, _0>,
Expand Down
5 changes: 5 additions & 0 deletions typings-checker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,8 @@ const e4: E1 = { a: 'foo', b: true, c: 1 }

type TTO = t.TupleToObject<[number, string]>
const tto1: TTO = { 0: 1, 1: 'foo' }

type FIVE = t.NumberToString[5]
const n2s1: FIVE = '5'
// $ExpectError Type '"6"' is not assignable to type '"5"'
const n2s2: FIVE = '6'