Skip to content

Commit

Permalink
refactor: split impl
Browse files Browse the repository at this point in the history
  • Loading branch information
unional committed Sep 27, 2023
1 parent de546a2 commit b8c0bc4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions type-plus/ts/bigint/strict_bigint_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ export type StrictBigintType<T, Then = T, Else = never> = IsAnyOrNever<
* type R = IsStrictBigint<unknown> // false
* ```
*/
export type IsStrictBigint<T, Then = true, Else = false> = StrictBigintType<T, Then, Else>
export type IsStrictBigint<T, Then = true, Else = false> = IsAnyOrNever<
T,
$SelectionBranch> extends infer R
? R extends $Then ? Else
: R extends $Else ? [bigint] extends [T] ? ([T] extends [bigint] ? (`${T}` extends `${number}` ? Else : Then) : Else) : Else
: never : never


/**
* Check if the type `T` is not exactly `bigint`.
Expand Down Expand Up @@ -60,4 +66,10 @@ export type NotStrictBigintType<T, Then = T, Else = never> = StrictBigintType<T,
* type R = IsNotStrictBigint<unknown> // true
* ```
*/
export type IsNotStrictBigint<T, Then = true, Else = false> = StrictBigintType<T, Else, Then>
export type IsNotStrictBigint<T, Then = true, Else = false> = IsAnyOrNever<
T,
$SelectionBranch> extends infer R
? R extends $Then ? Then
: R extends $Else ? [bigint] extends [T] ? ([T] extends [bigint] ? (`${T}` extends `${number}` ? Then : Else) : Then) : Then
: never : never

0 comments on commit b8c0bc4

Please sign in to comment.