diff --git a/src/types/helper.ts b/src/types/helper.ts index 142b4d8..e20fbd1 100644 --- a/src/types/helper.ts +++ b/src/types/helper.ts @@ -5,3 +5,9 @@ export type NoneBinary = T extends `${"1" | "0"}${infe : never export type isBinaryString = NoneBinary extends never ? never : T + +export type Binary< + T extends number, + R extends string = "", + Arr extends string[] = [] +> = Arr["length"] extends T ? R : Binary diff --git a/src/types/index.ts b/src/types/index.ts index 46fbe21..46a031a 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,4 +1,4 @@ -import { isBinaryString } from "./helper" +import { Binary, isBinaryString } from "./helper" export type BinaryString = { [K in keyof T]: isBinaryString @@ -6,12 +6,6 @@ export type BinaryString = { // type a = BinaryString<("00" | "10" | "01" | "11")[]> -export type Binary< - T extends number, - R extends string = "", - Arr extends string[] = [] -> = Arr["length"] extends T ? R : Binary - export type Struct< T extends number, R extends any[] = []