From 09dbb2e98ec20e898dc11dbb80c1ae6836e33faf Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 20 Mar 2019 11:03:32 -0500 Subject: [PATCH] type fixes --- types/parse/index.d.ts | 56 ++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 6c3aa122f1..da3fde2dc6 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -24,6 +24,10 @@ declare namespace Parse { let liveQueryServerURL: string; let VERSION: string; + interface BatchSizeOption { + batchSize?: number; + } + interface SuccessOption { success?: Function; } @@ -267,25 +271,25 @@ declare namespace Parse { constructor(attributes?: string[], options?: any); static createWithoutData(id: string): T; - static destroyAll(list: T[], options?: Object.DestroyAllOptions): Promise; - static extend(className: string, protoProps?: any, classProps?: any): any; + static destroyAll(list: T[], options?: Object.DestroyAllOptions): Promise; + static extend(className: string | { className: string }, protoProps?: any, classProps?: any): any; static fetchAll(list: T[], options: Object.FetchAllOptions): Promise; static fetchAllIfNeeded(list: T[], options: Object.FetchAllOptions): Promise; - static fetchAllWithInclude(list: any, keys: any, options: any): any; + static fetchAllWithInclude(list: T[], keys: string | Array>, options: Object.RequestOptions): any; static fromJSON(json: any, override: boolean): any; static pinAll(objects: Object[]): Promise; static pinAllWithName(name: string, objects: Object[]): Promise; static registerSubclass(className: string, clazz: new (options?: any) => T): void; static saveAll(list: T[], options?: Object.SaveAllOptions): Promise; - static unPinAll(objects: any): Promise; + static unPinAll(objects: Object[]): Promise; static unPinAllObjects(): Promise; - static unPinAllObjectsWithName(name: string): Promise; - static unPinAllWithName(...args: any[]): Promise; + static unPinAllObjectsWithName(name: string): Promise; + static unPinAllWithName(name: string, objects: Object[]): Promise; - add(attr: string, item: any): this; - addAll(attr: string, items: any[]): this; - addAllUnique(attr: string, items: any[]): this; - addUnique(attr: string, item: any): this; + add(attr: string, item: any): this | boolean; + addAll(attr: string, items: any[]): this | boolean; + addAllUnique(attr: string, items: any[]): this | boolean; + addUnique(attr: string, item: any): this | boolean; change(options: any): this; changedAttributes(diff: any): boolean; clear(options: any): any; @@ -298,7 +302,7 @@ declare namespace Parse { existed(): boolean; fetch(options?: Object.FetchOptions): Promise; fetchFromLocalDatastore(): Promise | void; - fetchWithInclude(keys: string[], options?: any): Promise; + fetchWithInclude(keys: keys: string | Array>, options?: Object.RequestOptions): Promise; get(attr: string): any | undefined; getACL(): ACL | undefined; has(attr: string): boolean; @@ -306,16 +310,16 @@ declare namespace Parse { increment(attr: string, amount?: number): any; initialize(): void; isNew(): boolean; - isPinned(...args: any[]): Promise; + isPinned(): Promise; isValid(): boolean; op(attr: string): any; - pin(): Promise; - pinWithName(name: string): Promise; + pin(): Promise; + pinWithName(name: string): Promise; previous(attr: string): any; previousAttributes(): any; relation(attr: string): Relation; - remove(attr: string, item: any): any; - removeAll(attr: string, items: any): any; + remove(attr: string, item: any): this | boolean; + removeAll(attr: string, items: any): this | boolean; revert(): void; save(attrs?: { [key: string]: any } | null, options?: Object.SaveOptions): Promise; save(key: string, value: any, options?: Object.SaveOptions): Promise; @@ -324,8 +328,8 @@ declare namespace Parse { set(attrs: object, options?: Object.SetOptions): boolean; setACL(acl: ACL, options?: SuccessFailureOptions): boolean; toPointer(): Pointer; - unPin(): Promise; - unPinWithName(name: string): Promise; + unPin(): Promise; + unPinWithName(name: string): Promise; unset(attr: string, options?: any): any; validate(attrs: any, options?: SuccessFailureOptions): boolean; } @@ -333,7 +337,7 @@ declare namespace Parse { namespace Object { interface DestroyOptions extends SuccessFailureOptions, WaitOption, ScopeOptions { } - interface DestroyAllOptions extends SuccessFailureOptions, ScopeOptions { } + interface DestroyAllOptions extends BatchSizeOption, ScopeOptions { } interface FetchAllOptions extends SuccessFailureOptions, ScopeOptions { } @@ -341,14 +345,14 @@ declare namespace Parse { interface SaveOptions extends SuccessFailureOptions, SilentOption, ScopeOptions, WaitOption { } - interface SaveAllOptions extends SuccessFailureOptions, ScopeOptions { } + interface SaveAllOptions extends BatchSizeOption, ScopeOptions { } interface SetOptions extends ErrorOption, SilentOption { promise?: any; } } - class Polygon extends BaseObject { + class Polygon extends BaseObject { constructor(arg1: GeoPoint[] | number[][]); containsPoint(point: GeoPoint): boolean; equals(other: Polygon | any): boolean; @@ -438,7 +442,7 @@ declare namespace Parse { constructor(objectClass: new (...args: any[]) => T); static and(...args: Query[]): Query; - static fromJSON(className: any, json: any): Query; + static fromJSON(className: string, json: any): Query; static nor(...args: Query[]): Query; static or(...var_args: Query[]): Query; @@ -453,7 +457,7 @@ declare namespace Parse { containedIn(key: string, values: any[]): Query; contains(key: string, substring: string): Query; containsAll(key: string, values: any[]): Query; - containsAllStartingWith(key: string, values: any[]): Query; + containsAllStartingWith(key: string, values: string[]): Query; count(options?: Query.CountOptions): Promise; descending(key: string): Query; descending(key: string[]): Query; @@ -489,10 +493,10 @@ declare namespace Parse { polygonContains(key: string, point: GeoPoint): Query; select(...keys: string[]): Query; skip(n: number): Query; - sortByTextScore(): any; + sortByTextScore(): this; startsWith(key: string, prefix: string): Query; subscribe(): LiveQuerySubscription; - withJSON(json: any): any; + withJSON(json: any): this; withinGeoBox(key: string, southwest: GeoPoint, northeast: GeoPoint): Query; withinKilometers(key: string, point: GeoPoint, maxDistance: number): Query; withinMiles(key: string, point: GeoPoint, maxDistance: number): Query; @@ -659,7 +663,7 @@ subscription.on('close', () => {}); class User extends Object { static allowCustomUserClass(isAllowed: boolean): void; - static become(sessionToken: string, options?: SuccessFailureOptions): Promise; + static become(sessionToken: string, options?: UseMasterKeyOption): Promise; static current(): User | undefined; static currentAsync(): Promise; static signUp(username: string, password: string, attrs: any, options?: SignUpOptions): Promise;