mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
[@types/react-native] Added progress event to XHR as per spec (#34902)
* Added to progress event to XHR as per spec * TEST: ProgressEvent
This commit is contained in:
committed by
Wesley Wigham
parent
2ed977bc7e
commit
671e555f44
Vendored
+21
-15
@@ -139,6 +139,12 @@ type ResponseType_ = "basic" | "cors" | "default" | "error" | "opaque" | "opaque
|
||||
// XMLHttpRequest
|
||||
//
|
||||
|
||||
declare interface ProgressEvent extends Event {
|
||||
readonly lengthComputable: boolean;
|
||||
readonly loaded: number;
|
||||
readonly total: number;
|
||||
}
|
||||
|
||||
interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap {
|
||||
readystatechange: Event;
|
||||
}
|
||||
@@ -193,23 +199,23 @@ declare var XMLHttpRequest: {
|
||||
};
|
||||
|
||||
interface XMLHttpRequestEventTargetEventMap {
|
||||
abort: Event;
|
||||
error: Event;
|
||||
load: Event;
|
||||
loadend: Event;
|
||||
loadstart: Event;
|
||||
progress: Event;
|
||||
timeout: Event;
|
||||
abort: ProgressEvent;
|
||||
error: ProgressEvent;
|
||||
load: ProgressEvent;
|
||||
loadend: ProgressEvent;
|
||||
loadstart: ProgressEvent;
|
||||
progress: ProgressEvent;
|
||||
timeout: ProgressEvent;
|
||||
}
|
||||
|
||||
interface XMLHttpRequestEventTarget {
|
||||
onabort: ((this: XMLHttpRequest, ev: Event) => any) | null;
|
||||
onerror: ((this: XMLHttpRequest, ev: Event) => any) | null;
|
||||
onload: ((this: XMLHttpRequest, ev: Event) => any) | null;
|
||||
onloadend: ((this: XMLHttpRequest, ev: Event) => any) | null;
|
||||
onloadstart: ((this: XMLHttpRequest, ev: Event) => any) | null;
|
||||
onprogress: ((this: XMLHttpRequest, ev: Event) => any) | null;
|
||||
ontimeout: ((this: XMLHttpRequest, ev: Event) => any) | null;
|
||||
onabort: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
|
||||
onerror: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
|
||||
onload: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
|
||||
onloadend: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
|
||||
onloadstart: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
|
||||
onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
|
||||
ontimeout: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
|
||||
addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(
|
||||
type: K,
|
||||
listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any
|
||||
@@ -240,4 +246,4 @@ declare var XMLHttpRequestUpload: {
|
||||
new (): XMLHttpRequestUpload;
|
||||
};
|
||||
|
||||
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
|
||||
declare type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
|
||||
|
||||
@@ -26,3 +26,11 @@ fetch(myRequest, myInit)
|
||||
const init = { status: 200, statusText: "SuperSmashingGreat!" };
|
||||
const myResponse = new Response(blob, init);
|
||||
});
|
||||
|
||||
const xmlRequest = new XMLHttpRequest();
|
||||
|
||||
xmlRequest.addEventListener("load", (ev) => {
|
||||
console.log(ev.lengthComputable)
|
||||
console.log(ev.loaded)
|
||||
console.log(ev.total)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user