Skip to content

Commit ea94a16

Browse files
committed
build:types
1 parent 74a7067 commit ea94a16

File tree

4 files changed

+23
-38
lines changed

4 files changed

+23
-38
lines changed

src/ParseFile.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ class ParseFile {
156156
* </pre>
157157
* @returns {Promise} Promise that is resolve with base64 data
158158
*/
159-
async getData(options): Promise<string> {
159+
async getData(options?: { progress?: () => void }): Promise<string> {
160160
options = options || {};
161161
if (this._data) {
162162
return this._data;
163163
}
164164
if (!this._url) {
165165
throw new Error('Cannot retrieve data for unsaved ParseFile.');
166166
}
167-
options.requestTask = task => (this._requestTask = task);
167+
(options as any).requestTask = task => (this._requestTask = task);
168168
const controller = CoreManager.getFileController();
169169
const result = await controller.download(this._url, options);
170170
this._data = result.base64;

types/ParseFile.d.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,23 @@ declare class ParseFile {
7878
* Data is present if initialized with Byte Array, Base64 or Saved with Uri.
7979
* Data is cleared if saved with File object selected with a file upload control
8080
*
81+
* @param {object} options
82+
* @param {function} [options.progress] callback for download progress
83+
* <pre>
84+
* const parseFile = new Parse.File(name, file);
85+
* parseFile.getData({
86+
* progress: (progressValue, loaded, total) => {
87+
* if (progressValue !== null) {
88+
* // Update the UI using progressValue
89+
* }
90+
* }
91+
* });
92+
* </pre>
8193
* @returns {Promise} Promise that is resolve with base64 data
8294
*/
83-
getData(): Promise<string>;
95+
getData(options?: {
96+
progress?: () => void;
97+
}): Promise<string>;
8498
/**
8599
* Gets the name of the file. Before save is called, this is the filename
86100
* given by the user. After save is called, that name gets prefixed with a
@@ -121,12 +135,12 @@ declare class ParseFile {
121135
* be used for this request.
122136
* <li>sessionToken: A valid session token, used for making a request on
123137
* behalf of a specific user.
124-
* <li>progress: In Browser only, callback for upload progress. For example:
138+
* <li>progress: callback for upload progress. For example:
125139
* <pre>
126140
* let parseFile = new Parse.File(name, file);
127141
* parseFile.save({
128-
* progress: (progressValue, loaded, total, { type }) => {
129-
* if (type === "upload" && progressValue !== null) {
142+
* progress: (progressValue, loaded, total) => {
143+
* if (progressValue !== null) {
130144
* // Update the UI using progressValue
131145
* }
132146
* }

types/RESTController.d.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ declare const RESTController: {
2828
reject: (err: any) => void;
2929
}) | Promise<unknown>;
3030
request(method: string, path: string, data: any, options?: RequestOptions): Promise<any>;
31-
handleError(response: any): Promise<never>;
32-
_setXHR(xhr: any): void;
33-
_getXHR(): any;
31+
handleError(errorJSON: any): Promise<never>;
3432
};
3533
export default RESTController;

types/Xhr.weapp.d.ts

+2-29
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,2 @@
1-
declare class XhrWeapp {
2-
UNSENT: number;
3-
OPENED: number;
4-
HEADERS_RECEIVED: number;
5-
LOADING: number;
6-
DONE: number;
7-
header: any;
8-
readyState: any;
9-
status: number;
10-
response: string | undefined;
11-
responseType: string;
12-
responseText: string;
13-
responseHeader: any;
14-
method: string;
15-
url: string;
16-
onabort: () => void;
17-
onprogress: () => void;
18-
onerror: () => void;
19-
onreadystatechange: () => void;
20-
requestTask: any;
21-
constructor();
22-
getAllResponseHeaders(): string;
23-
getResponseHeader(key: any): any;
24-
setRequestHeader(key: any, value: any): void;
25-
open(method: any, url: any): void;
26-
abort(): void;
27-
send(data: any): void;
28-
}
29-
export default XhrWeapp;
1+
export declare const TEXT_FILE_EXTS: RegExp;
2+
export declare function polyfillFetch(): void;

0 commit comments

Comments
 (0)