-
Notifications
You must be signed in to change notification settings - Fork 0
/
bigint.ts
26 lines (22 loc) · 895 Bytes
/
bigint.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
export type { bigint }
import type { any } from "../any/exports.js"
import type { never } from "../never/exports.js"
declare namespace bigint {
type is<x> = [x] extends [bigint] ? true : false
namespace is {
type literal<x> = [x] extends [bigint] ? [bigint] extends [x] ? false : true : false
type universal<x> = [bigint] extends [x] ? true : false
}
type parse<type>
= [type] extends [bigint] ? type
: [type] extends [any.key]
? [`${type}`] extends [`${infer x extends number}n`] ? bigint.parse<x>
: [`${type}`] extends [`${infer x extends bigint}`] ? x
: never.close.unmatched_expr
: never.close.unmatched_expr
;
namespace parse {
type literal<type> = [bigint] extends [type] ? never.as.nothing : bigint.parse<type>
type universal<type> = [bigint] extends [type] ? type : [`${bigint}`] extends [type] ? bigint : never.as.nothing
}
}