@@ -14,11 +14,11 @@ export type BeforeRequestHook = (
14
14
) => Request | Response | void | Promise < Request | Response | void > ;
15
15
16
16
export type BeforeRetryHook = ( options : {
17
- request : Request ,
18
- response : Response ,
19
- options : NormalizedOptions ,
20
- error : Error ,
21
- retryCount : number ,
17
+ request : Request ;
18
+ response : Response ;
19
+ options : NormalizedOptions ;
20
+ error : Error ;
21
+ retryCount : number ;
22
22
} ) => void | Promise < void > ;
23
23
24
24
export type AfterResponseHook = (
@@ -329,11 +329,11 @@ export interface NormalizedOptions extends RequestInit {
329
329
Returns a `Response` object with `Body` methods added for convenience. So you can, for example, call `ky.get(input).json()` directly without having to await the `Response` first. When called like that, an appropriate `Accept` header will be set depending on the body method used. Unlike the `Body` methods of `window.Fetch`; these will throw an `HTTPError` if the response status is not in the range of `200...299`. Also, `.json()` will return an empty string if the response status is `204` instead of throwing a parse error due to an empty body.
330
330
*/
331
331
export interface ResponsePromise extends Promise < Response > {
332
- arrayBuffer ( ) : Promise < ArrayBuffer > ;
332
+ arrayBuffer : ( ) => Promise < ArrayBuffer > ;
333
333
334
- blob ( ) : Promise < Blob > ;
334
+ blob : ( ) => Promise < Blob > ;
335
335
336
- formData ( ) : Promise < FormData > ;
336
+ formData : ( ) => Promise < FormData > ;
337
337
338
338
// TODO: Use `json<T extends JSONValue>(): Promise<T>;` when it's fixed in TS.
339
339
// See https://github.com/microsoft/TypeScript/issues/15300 and https://github.com/sindresorhus/ky/pull/80
@@ -358,9 +358,9 @@ export interface ResponsePromise extends Promise<Response> {
358
358
const result = await ky(…).json<Result>();
359
359
```
360
360
*/
361
- json < T > ( ) : Promise < T > ;
361
+ json : < T > ( ) => Promise < T > ;
362
362
363
- text ( ) : Promise < string > ;
363
+ text : ( ) => Promise < string > ;
364
364
}
365
365
366
366
/**
@@ -405,54 +405,54 @@ declare const ky: {
405
405
@param url - `Request` object, `URL` object, or URL string.
406
406
@returns A promise with `Body` methods added.
407
407
*/
408
- get ( url : Input , options ?: Options ) : ResponsePromise ;
408
+ get : ( url : Input , options ?: Options ) => ResponsePromise ;
409
409
410
410
/**
411
411
Fetch the given `url` using the option `{method: 'post'}`.
412
412
413
413
@param url - `Request` object, `URL` object, or URL string.
414
414
@returns A promise with `Body` methods added.
415
415
*/
416
- post ( url : Input , options ?: Options ) : ResponsePromise ;
416
+ post : ( url : Input , options ?: Options ) => ResponsePromise ;
417
417
418
418
/**
419
419
Fetch the given `url` using the option `{method: 'put'}`.
420
420
421
421
@param url - `Request` object, `URL` object, or URL string.
422
422
@returns A promise with `Body` methods added.
423
423
*/
424
- put ( url : Input , options ?: Options ) : ResponsePromise ;
424
+ put : ( url : Input , options ?: Options ) => ResponsePromise ;
425
425
426
426
/**
427
427
Fetch the given `url` using the option `{method: 'delete'}`.
428
428
429
429
@param url - `Request` object, `URL` object, or URL string.
430
430
@returns A promise with `Body` methods added.
431
431
*/
432
- delete ( url : Input , options ?: Options ) : ResponsePromise ;
432
+ delete : ( url : Input , options ?: Options ) => ResponsePromise ;
433
433
434
434
/**
435
435
Fetch the given `url` using the option `{method: 'patch'}`.
436
436
437
437
@param url - `Request` object, `URL` object, or URL string.
438
438
@returns A promise with `Body` methods added.
439
439
*/
440
- patch ( url : Input , options ?: Options ) : ResponsePromise ;
440
+ patch : ( url : Input , options ?: Options ) => ResponsePromise ;
441
441
442
442
/**
443
443
Fetch the given `url` using the option `{method: 'head'}`.
444
444
445
445
@param url - `Request` object, `URL` object, or URL string.
446
446
@returns A promise with `Body` methods added.
447
447
*/
448
- head ( url : Input , options ?: Options ) : ResponsePromise ;
448
+ head : ( url : Input , options ?: Options ) => ResponsePromise ;
449
449
450
450
/**
451
451
Create a new Ky instance with complete new defaults.
452
452
453
453
@returns A new Ky instance.
454
454
*/
455
- create ( defaultOptions : Options ) : typeof ky ;
455
+ create : ( defaultOptions : Options ) => typeof ky ;
456
456
457
457
/**
458
458
Create a new Ky instance with some defaults overridden with your own.
@@ -461,7 +461,7 @@ declare const ky: {
461
461
462
462
@returns A new Ky instance.
463
463
*/
464
- extend ( defaultOptions : Options ) : typeof ky ;
464
+ extend : ( defaultOptions : Options ) => typeof ky ;
465
465
466
466
/**
467
467
A `Symbol` that can be returned by a `beforeRetry` hook to stop the retry.
@@ -493,8 +493,8 @@ declare const ky: {
493
493
} ;
494
494
495
495
declare namespace ky {
496
- export type TimeoutError = InstanceType < typeof ky . TimeoutError > ;
497
- export type HTTPError = InstanceType < typeof ky . HTTPError > ;
496
+ export type TimeoutError = InstanceType < typeof TimeoutError > ;
497
+ export type HTTPError = InstanceType < typeof HTTPError > ;
498
498
}
499
499
500
500
export default ky ;
0 commit comments