Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3529666
D9711.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D9711.diff
View Options
diff --git a/lib/utils/action-utils.js b/lib/utils/action-utils.js
--- a/lib/utils/action-utils.js
+++ b/lib/utils/action-utils.js
@@ -282,7 +282,7 @@
) => {
const startingPayload = { ...inputStartingPayload, logInActionSource };
dispatch(wrapActionPromise(actionTypes, promise, null, startingPayload));
- return new Promise(r => (callServerEndpointCallback = r));
+ return new Promise<boolean>(r => (callServerEndpointCallback = r));
};
await resolveInvalidatedCookie(
boundCallServerEndpoint,
@@ -340,7 +340,9 @@
return Promise.resolve(null);
}
// Wait to run until we get our new cookie
- return new Promise(r => serverEndpointCallsWaitingForNewCookie.push(r));
+ return new Promise<?CallServerEndpoint>(r =>
+ serverEndpointCallsWaitingForNewCookie.push(r),
+ );
};
// This function is a helper for the next function defined below
const attemptToResolveInvalidation = async (
@@ -387,7 +389,9 @@
return Promise.resolve(null);
}
if (currentlyWaitingForNewCookie) {
- return new Promise(r => serverEndpointCallsWaitingForNewCookie.push(r));
+ return new Promise<?CallServerEndpoint>(r =>
+ serverEndpointCallsWaitingForNewCookie.push(r),
+ );
}
currentlyWaitingForNewCookie = true;
return attemptToResolveInvalidation(sessionChange);
diff --git a/lib/utils/blob-service-upload.js b/lib/utils/blob-service-upload.js
--- a/lib/utils/blob-service-upload.js
+++ b/lib/utils/blob-service-upload.js
@@ -42,7 +42,7 @@
}
let failed = false;
- const responsePromise = new Promise((resolve, reject) => {
+ const responsePromise = new Promise<void>((resolve, reject) => {
xhr.onload = () => {
if (failed) {
return;
diff --git a/lib/utils/upload-blob.js b/lib/utils/upload-blob.js
--- a/lib/utils/upload-blob.js
+++ b/lib/utils/upload-blob.js
@@ -66,41 +66,43 @@
}
let failed = false;
- const responsePromise = new Promise((resolve, reject) => {
- xhr.onload = () => {
- if (failed) {
- return;
- }
- const text = xhr.responseText;
- try {
- resolve(JSON.parse(text));
- } catch (e) {
- console.log(text);
- reject(e);
- }
- };
- xhr.onabort = () => {
- failed = true;
- reject(new Error('request aborted'));
- };
- xhr.onerror = event => {
- failed = true;
- reject(event);
- };
- if (options && options.timeout) {
- xhr.ontimeout = event => {
- failed = true;
- reject(event);
+ const responsePromise = new Promise<CallServerEndpointResponse>(
+ (resolve, reject) => {
+ xhr.onload = () => {
+ if (failed) {
+ return;
+ }
+ const text = xhr.responseText;
+ try {
+ resolve(JSON.parse(text));
+ } catch (e) {
+ console.log(text);
+ reject(e);
+ }
};
- }
- if (options && options.abortHandler) {
- options.abortHandler(() => {
+ xhr.onabort = () => {
failed = true;
reject(new Error('request aborted'));
- xhr.abort();
- });
- }
- });
+ };
+ xhr.onerror = event => {
+ failed = true;
+ reject(event);
+ };
+ if (options && options.timeout) {
+ xhr.ontimeout = event => {
+ failed = true;
+ reject(event);
+ };
+ }
+ if (options && options.abortHandler) {
+ options.abortHandler(() => {
+ failed = true;
+ reject(new Error('request aborted'));
+ xhr.abort();
+ });
+ }
+ },
+ );
if (!failed) {
xhr.send(formData);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 8:42 PM (1 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2703121
Default Alt Text
D9711.diff (3 KB)
Attached To
Mode
D9711: [Flow202][lib][skip-ci] [19/23] Fix Flow issues in unparameterized Promise constructors
Attached
Detach File
Event Timeline
Log In to Comment