From 9893fc9a5eb9f9a3cb623ec02df41ecf814b796e Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 27 Oct 2022 15:40:18 +0400 Subject: [PATCH] Update fetch and uploader --- src/asset_manager/view/FileUploader.ts | 2 +- src/utils/fetch.ts | 3 +-- src/utils/promise-polyfill.d.ts | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 src/utils/promise-polyfill.d.ts diff --git a/src/asset_manager/view/FileUploader.ts b/src/asset_manager/view/FileUploader.ts index 9ef69c8e5..ec51c40ee 100644 --- a/src/asset_manager/view/FileUploader.ts +++ b/src/asset_manager/view/FileUploader.ts @@ -392,7 +392,7 @@ export default class FileUploaderView extends View { promises.push(promise); } - Promise.all(promises).then( + return Promise.all(promises).then( data => { response.data = data; // @ts-ignore diff --git a/src/utils/fetch.ts b/src/utils/fetch.ts index 9205fe6c5..32c4285cb 100644 --- a/src/utils/fetch.ts +++ b/src/utils/fetch.ts @@ -1,4 +1,3 @@ -// @ts-ignore import Promise from 'promise-polyfill'; import { hasWin } from './mixins'; @@ -10,7 +9,7 @@ export default typeof fetch == 'function' ? // @ts-ignore fetch.bind() : (url: string, options: Record) => { - return new Promise((res: any, rej: any) => { + return new Promise((res, rej) => { const req = new XMLHttpRequest(); req.open(options.method || 'get', url); req.withCredentials = options.credentials == 'include'; diff --git a/src/utils/promise-polyfill.d.ts b/src/utils/promise-polyfill.d.ts new file mode 100644 index 000000000..7a63bf53c --- /dev/null +++ b/src/utils/promise-polyfill.d.ts @@ -0,0 +1,4 @@ +declare module 'promise-polyfill' { + const defType: PromiseConstructor; + export default defType; +}