source: frontend/node_modules/whatwg-fetch/fetch.js.flow

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/* @flow strict */
2
3type CredentialsType = 'omit' | 'same-origin' | 'include'
4
5type ResponseType = 'default' | 'error'
6
7type BodyInit = string | URLSearchParams | FormData | Blob | ArrayBuffer | $ArrayBufferView
8
9type RequestInfo = Request | URL | string
10
11type RequestOptions = {|
12 body?: ?BodyInit;
13
14 credentials?: CredentialsType;
15 headers?: HeadersInit;
16 method?: string;
17 mode?: string;
18 referrer?: string;
19 signal?: ?AbortSignal;
20|}
21
22type ResponseOptions = {|
23 status?: number;
24 statusText?: string;
25 headers?: HeadersInit;
26|}
27
28type HeadersInit = Headers | {[string]: string}
29
30// https://github.com/facebook/flow/blob/f68b89a5012bd995ab3509e7a41b7325045c4045/lib/bom.js#L902-L914
31declare class Headers {
32 @@iterator(): Iterator<[string, string]>;
33 constructor(init?: HeadersInit): void;
34 append(name: string, value: string): void;
35 delete(name: string): void;
36 entries(): Iterator<[string, string]>;
37 forEach((value: string, name: string, headers: Headers) => any, thisArg?: any): void;
38 get(name: string): null | string;
39 has(name: string): boolean;
40 keys(): Iterator<string>;
41 set(name: string, value: string): void;
42 values(): Iterator<string>;
43}
44
45// https://github.com/facebook/flow/pull/6548
46interface AbortSignal {
47 aborted: boolean;
48 addEventListener(type: string, listener: (Event) => mixed, options?: EventListenerOptionsOrUseCapture): void;
49 removeEventListener(type: string, listener: (Event) => mixed, options?: EventListenerOptionsOrUseCapture): void;
50}
51
52// https://github.com/facebook/flow/blob/f68b89a5012bd995ab3509e7a41b7325045c4045/lib/bom.js#L994-L1018
53// unsupported in polyfill:
54// - cache
55// - integrity
56// - redirect
57// - referrerPolicy
58declare class Request {
59 constructor(input: RequestInfo, init?: RequestOptions): void;
60 clone(): Request;
61
62 url: string;
63
64 credentials: CredentialsType;
65 headers: Headers;
66 method: string;
67 mode: ModeType;
68 referrer: string;
69 signal: ?AbortSignal;
70
71 // Body methods and attributes
72 bodyUsed: boolean;
73
74 arrayBuffer(): Promise<ArrayBuffer>;
75 blob(): Promise<Blob>;
76 formData(): Promise<FormData>;
77 json(): Promise<any>;
78 text(): Promise<string>;
79}
80
81// https://github.com/facebook/flow/blob/f68b89a5012bd995ab3509e7a41b7325045c4045/lib/bom.js#L968-L992
82// unsupported in polyfill:
83// - body
84// - redirected
85// - trailer
86declare class Response {
87 constructor(input?: ?BodyInit, init?: ResponseOptions): void;
88 clone(): Response;
89 static error(): Response;
90 static redirect(url: string, status?: number): Response;
91
92 type: ResponseType;
93 url: string;
94 ok: boolean;
95 status: number;
96 statusText: string;
97 headers: Headers;
98
99 // Body methods and attributes
100 bodyUsed: boolean;
101
102 arrayBuffer(): Promise<ArrayBuffer>;
103 blob(): Promise<Blob>;
104 formData(): Promise<FormData>;
105 json(): Promise<any>;
106 text(): Promise<string>;
107}
108
109declare class DOMException extends Error {
110 constructor(message?: string, name?: string): void;
111}
112
113declare module.exports: {
114 fetch(input: RequestInfo, init?: RequestOptions): Promise<Response>;
115 Headers: typeof Headers;
116 Request: typeof Request;
117 Response: typeof Response;
118 DOMException: typeof DOMException;
119}
Note: See TracBrowser for help on using the repository browser.