@@ -47,21 +47,9 @@ export interface ResponseBody {
4747 json ( ) : Promise < unknown > ;
4848}
4949
50- /**
51- * Represents an HTTP status code including the default
52- * status codes and the 1XX, 4XX, 5XX ranges.
53- */
54- export type EnhancedHTTPStatus =
55- | 'default'
56- | '1XX'
57- | '2XX'
58- | '3XX'
59- | '4XX'
60- | '5XX'
61- | 100
62- | 101
63- | 102
64- | 103
50+ export type HTTPStatus1XX = 100 | 101 | 102 | 103 ;
51+
52+ export type HTTPStatus2XX =
6553 | 200
6654 | 201
6755 | 202
@@ -71,16 +59,11 @@ export type EnhancedHTTPStatus =
7159 | 206
7260 | 207
7361 | 208
74- | 226
75- | 300
76- | 301
77- | 302
78- | 303
79- | 304
80- | 305
81- | 306
82- | 307
83- | 308
62+ | 226 ;
63+
64+ export type HTTPStatus3XX = 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 ;
65+
66+ export type HTTPStatus4XX =
8467 | 400
8568 | 401
8669 | 402
@@ -111,7 +94,9 @@ export type EnhancedHTTPStatus =
11194 | 429
11295 | 430
11396 | 431
114- | 451
97+ | 451 ;
98+
99+ export type HTTPStatus5XX =
115100 | 500
116101 | 501
117102 | 502
@@ -126,32 +111,28 @@ export type EnhancedHTTPStatus =
126111 | 511 ;
127112
128113/**
129- * Extracts only the successful status codes of EnhancedHTTPStatus.
114+ * Represents an HTTP status code including the default
115+ * status codes and the 1XX, 4XX, 5XX ranges.
130116 */
131- export type SuccessfulStatus = Extract <
132- EnhancedHTTPStatus ,
117+ export type EnhancedHTTPStatus =
133118 | 'default'
119+ | '1XX'
120+ | HTTPStatus1XX
134121 | '2XX'
135- | 200
136- | 201
137- | 202
138- | 203
139- | 204
140- | 205
141- | 206
142- | 207
143- | 208
144- | 226
122+ | HTTPStatus2XX
145123 | '3XX'
146- | 300
147- | 301
148- | 302
149- | 303
150- | 304
151- | 305
152- | 306
153- | 307
154- | 308
124+ | HTTPStatus3XX
125+ | '4XX'
126+ | HTTPStatus4XX
127+ | '5XX'
128+ | HTTPStatus5XX ;
129+
130+ /**
131+ * Extracts only the successful status codes of EnhancedHTTPStatus.
132+ */
133+ export type SuccessfulStatus = Extract <
134+ EnhancedHTTPStatus ,
135+ 'default' | '2XX' | HTTPStatus2XX | '3XX' | HTTPStatus3XX
155136> ;
156137
157138/**
@@ -166,7 +147,19 @@ export type StatusResponse<
166147 headers : Record < string , string > ;
167148 ok : S extends SuccessfulStatus ? true : S extends 'default' ? boolean : false ;
168149 // When using ranges or default, we can't now the specific status code.
169- status : S extends string ? number : S ;
150+ status : S extends '1XX'
151+ ? HTTPStatus1XX
152+ : S extends '2XX'
153+ ? HTTPStatus2XX
154+ : S extends '3XX'
155+ ? HTTPStatus3XX
156+ : S extends '4XX'
157+ ? HTTPStatus4XX
158+ : S extends '5XX'
159+ ? HTTPStatus5XX
160+ : S extends 'default'
161+ ? number
162+ : S ;
170163} ;
171164
172165export type BaseFetcherData = {
0 commit comments