UNPKG

946 BTypeScriptView Raw
1type NumericAscii = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0";
2type NonNumericAscii<S> = S extends `${NumericAscii}` ? never : any;
3
4type IsNumericString<S extends string> = S extends `${number}` ? any : never;
5
6type IsNonNumericString<S extends string> = S extends `${NonNumericAscii<S>}${infer _}` ? any : never;
7
8export = status;
9
10declare const status: status;
11
12interface status {
13 (code: number): string;
14 <S extends string>(code: S): status.Result<S>;
15
16 codes: number[];
17 code: { [msg: string]: number | undefined };
18 empty: { [code: number]: boolean | undefined };
19 message: { [code: number]: string | undefined };
20 redirect: { [code: number]: boolean | undefined };
21 retry: { [code: number]: boolean | undefined };
22}
23
24declare namespace status {
25 type Result<S extends string> = S extends IsNumericString<S> ? string
26 : S extends IsNonNumericString<S> ? number
27 : string | number;
28}