From 246d148897b42d6c187a0a34916366610b195dac Mon Sep 17 00:00:00 2001 From: David Poetzsch-Heffter Date: Mon, 10 Apr 2017 22:37:29 +0200 Subject: [PATCH 1/7] Improvements to the parse typing & making the parse typing compatible with strict null checking --- types/parse/index.d.ts | 173 +++++++++++++++++++------------------ types/parse/parse-tests.ts | 23 +++-- types/parse/tsconfig.json | 4 +- 3 files changed, 107 insertions(+), 93 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index ec130f8ffe..c3bfa231d9 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Parse v1.2.19 // Project: https://parse.com/ -// Definitions by: Ullisen Media Group +// Definitions by: Ullisen Media Group , David Poetzsch-Heffter // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -10,8 +10,8 @@ declare namespace Parse { var applicationId: string; - var javaScriptKey: string; - var masterKey: string; + var javaScriptKey: string | undefined; + var masterKey: string | undefined; var serverURL: string; var VERSION: string; @@ -191,7 +191,7 @@ declare namespace Parse { constructor(name: string, data: any, type?: string); name(): string; url(): string; - save(options?: SuccessFailureOptions): Promise; + save(options?: SuccessFailureOptions): Promise; } @@ -267,22 +267,26 @@ declare namespace Parse { * A class that is used to access all of the children of a many-to-many relationship. * Each instance of Parse.Relation is associated with a particular parent object and key. */ - class Relation extends BaseObject { + class Relation extends BaseObject { - parent: Object; + parent: S; key: string; targetClassName: string; - constructor(parent?: Object, key?: string); + constructor(parent?: S, key?: string); //Adds a Parse.Object or an array of Parse.Objects to the relation. - add(object: Object): void; + add(object: T): void; // Returns a Parse.Query that is limited to objects in this relation. - query(): Query; + query(): Query; // Removes a Parse.Object or an array of Parse.Objects from this relation. - remove(object: Object): void; + remove(object: T): void; + } + + interface ObjectConstructor { + new (options?: any): T; } /** @@ -326,12 +330,12 @@ declare namespace Parse { constructor(attributes?: string[], options?: any); static extend(className: string, protoProps?: any, classProps?: any): any; - static fetchAll(list: Object[], options: SuccessFailureOptions): Promise; - static fetchAllIfNeeded(list: Object[], options: SuccessFailureOptions): Promise; - static destroyAll(list: Object[], options?: Object.DestroyAllOptions): Promise; + static fetchAll(list: T[], options: SuccessFailureOptions): Promise; + static fetchAllIfNeeded(list: T[], options: SuccessFailureOptions): Promise; + static destroyAll(list: T[], options?: Object.DestroyAllOptions): Promise; static saveAll(list: T[], options?: Object.SaveAllOptions): Promise; - static registerSubclass(className: string, clazz: new (options?: any) => T): void; + static registerSubclass(className: string, clazz: ObjectConstructor): void; initialize(): void; add(attr: string, item: any): Object; @@ -340,14 +344,14 @@ declare namespace Parse { changedAttributes(diff: any): boolean; clear(options: any): any; clone(): Object; - destroy(options?: Object.DestroyOptions): Promise; + destroy(options?: Object.DestroyOptions): Promise; dirty(attr: String): boolean; dirtyKeys(): string[]; escape(attr: string): string; existed(): boolean; - fetch(options?: Object.FetchOptions): Promise; - get(attr: string): any; - getACL(): ACL; + fetch(options?: Object.FetchOptions): Promise; + get(attr: string): any | undefined; + getACL(): ACL | undefined; has(attr: string): boolean; hasChanged(attr: string): boolean; increment(attr: string, amount?: number): any; @@ -355,10 +359,10 @@ declare namespace Parse { op(attr: string): any; previous(attr: string): any; previousAttributes(): any; - relation(attr: string): Relation; + relation(attr: string): Relation; remove(attr: string, item: any): any; - save(attrs?: { [key: string]: any }, options?: Object.SaveOptions): Promise; - save(key: string, value: any, options?: Object.SaveOptions): Promise; + save(attrs?: { [key: string]: any }, options?: Object.SaveOptions): Promise; + save(key: string, value: any, options?: Object.SaveOptions): Promise; set(key: string, value: any, options?: Object.SetOptions): boolean; setACL(acl: ACL, options?: SuccessFailureOptions): boolean; unset(attr: string, options?: any): any; @@ -429,7 +433,7 @@ declare namespace Parse { model: Object; models: Object[]; - query: Query; + query: Query; comparator: (object: Object) => any; constructor(models?: Object[], options?: Collection.Options); @@ -454,7 +458,7 @@ declare namespace Parse { namespace Collection { interface Options { model?: Object; - query?: Query; + query?: Query; comparator?: string; } @@ -508,7 +512,7 @@ declare namespace Parse { static unbind(): Events; on(eventName: string, callback?: Function, context?: any): Events; - off(eventName?: string, callback?: Function, context?: any): Events; + off(eventName?: string | null, callback?: Function | null, context?: any): Events; trigger(eventName: string, ...args: any[]): Events; bind(eventName: string, callback: Function, context?: any): Events; unbind(eventName?: string, callback?: Function, context?: any): Events; @@ -571,58 +575,59 @@ declare namespace Parse { * } * });

*/ - class Query extends BaseObject { + class Query extends BaseObject { objectClass: any; className: string; - constructor(objectClass: any); + constructor(objectClass: string); + constructor(objectClass: ObjectConstructor); - static or(...var_args: Query[]): Query; + static or(...var_args: Query[]): Query; - addAscending(key: string): Query; - addAscending(key: string[]): Query; - addDescending(key: string): Query; - addDescending(key: string[]): Query; - ascending(key: string): Query; - ascending(key: string[]): Query; + addAscending(key: string): Query; + addAscending(key: string[]): Query; + addDescending(key: string): Query; + addDescending(key: string[]): Query; + ascending(key: string): Query; + ascending(key: string[]): Query; collection(items?: Object[], options?: Collection.Options): Collection; - containedIn(key: string, values: any[]): Query; - contains(key: string, substring: string): Query; - containsAll(key: string, values: any[]): Query; - count(options?: Query.CountOptions): Promise; - descending(key: string): Query; - descending(key: string[]): Query; - doesNotExist(key: string): Query; - doesNotMatchKeyInQuery(key: string, queryKey: string, query: Query): Query; - doesNotMatchQuery(key: string, query: Query): Query; - each(callback: Function, options?: Query.EachOptions): Promise; - endsWith(key: string, suffix: string): Query; - equalTo(key: string, value: any): Query; - exists(key: string): Query; - find(options?: Query.FindOptions): Promise; - first(options?: Query.FirstOptions): Promise; - get(objectId: string, options?: Query.GetOptions): Promise; - greaterThan(key: string, value: any): Query; - greaterThanOrEqualTo(key: string, value: any): Query; - include(key: string): Query; - include(keys: string[]): Query; - lessThan(key: string, value: any): Query; - lessThanOrEqualTo(key: string, value: any): Query; - limit(n: number): Query; - matches(key: string, regex: RegExp, modifiers: any): Query; - matchesKeyInQuery(key: string, queryKey: string, query: Query): Query; - matchesQuery(key: string, query: Query): Query; - near(key: string, point: GeoPoint): Query; - notContainedIn(key: string, values: any[]): Query; - notEqualTo(key: string, value: any): Query; - select(...keys: string[]): Query; - skip(n: number): Query; - startsWith(key: string, prefix: string): Query; - withinGeoBox(key: string, southwest: GeoPoint, northeast: GeoPoint): Query; - withinKilometers(key: string, point: GeoPoint, maxDistance: number): Query; - withinMiles(key: string, point: GeoPoint, maxDistance: number): Query; - withinRadians(key: string, point: GeoPoint, maxDistance: number): Query; + containedIn(key: string, values: any[]): Query; + contains(key: string, substring: string): Query; + containsAll(key: string, values: any[]): Query; + count(options?: Query.CountOptions): Promise; + descending(key: string): Query; + descending(key: string[]): Query; + doesNotExist(key: string): Query; + doesNotMatchKeyInQuery(key: string, queryKey: string, query: Query): Query; + doesNotMatchQuery(key: string, query: Query): Query; + each(callback: Function, options?: Query.EachOptions): Promise; + endsWith(key: string, suffix: string): Query; + equalTo(key: string, value: any): Query; + exists(key: string): Query; + find(options?: Query.FindOptions): Promise; + first(options?: Query.FirstOptions): Promise; + get(objectId: string, options?: Query.GetOptions): Promise; + greaterThan(key: string, value: any): Query; + greaterThanOrEqualTo(key: string, value: any): Query; + include(key: string): Query; + include(keys: string[]): Query; + lessThan(key: string, value: any): Query; + lessThanOrEqualTo(key: string, value: any): Query; + limit(n: number): Query; + matches(key: string, regex: RegExp, modifiers: any): Query; + matchesKeyInQuery(key: string, queryKey: string, query: Query): Query; + matchesQuery(key: string, query: Query): Query; + near(key: string, point: GeoPoint): Query; + notContainedIn(key: string, values: any[]): Query; + notEqualTo(key: string, value: any): Query; + select(...keys: string[]): Query; + skip(n: number): Query; + startsWith(key: string, prefix: string): Query; + withinGeoBox(key: string, southwest: GeoPoint, northeast: GeoPoint): Query; + withinKilometers(key: string, point: GeoPoint, maxDistance: number): Query; + withinMiles(key: string, point: GeoPoint, maxDistance: number): Query; + withinRadians(key: string, point: GeoPoint, maxDistance: number): Query; } namespace Query { @@ -650,8 +655,8 @@ declare namespace Parse { constructor(name: string, acl: ACL); - getRoles(): Relation; - getUsers(): Relation; + getRoles(): Relation; + getUsers(): Relation; getName(): string; setName(name: string, options?: SuccessFailureOptions): any; } @@ -720,24 +725,24 @@ declare namespace Parse { */ class User extends Object { - static current(): User; - static signUp(username: string, password: string, attrs: any, options?: SuccessFailureOptions): Promise; - static logIn(username: string, password: string, options?: SuccessFailureOptions): Promise; - static logOut(): Promise; + static current(): User | undefined; + static signUp(username: string, password: string, attrs: any, options?: SuccessFailureOptions): Promise; + static logIn(username: string, password: string, options?: SuccessFailureOptions): Promise; + static logOut(): Promise; static allowCustomUserClass(isAllowed: boolean): void; - static become(sessionToken: string, options?: SuccessFailureOptions): Promise; - static requestPasswordReset(email: string, options?: SuccessFailureOptions): Promise; + static become(sessionToken: string, options?: SuccessFailureOptions): Promise; + static requestPasswordReset(email: string, options?: SuccessFailureOptions): Promise; static extend(protoProps?: any, classProps?: any): any; - signUp(attrs: any, options?: SuccessFailureOptions): Promise; - logIn(options?: SuccessFailureOptions): Promise; + signUp(attrs: any, options?: SuccessFailureOptions): Promise; + logIn(options?: SuccessFailureOptions): Promise; authenticated(): boolean; isCurrent(): boolean; - getEmail(): string; + getEmail(): string | undefined; setEmail(email: string, options: SuccessFailureOptions): boolean; - getUsername(): string; + getUsername(): string | undefined; setUsername(username: string, options?: SuccessFailureOptions): boolean; setPassword(password: string, options?: SuccessFailureOptions): boolean; @@ -801,7 +806,7 @@ declare namespace Parse { namespace Analytics { - function track(name: string, dimensions: any):Promise; + function track(name: string, dimensions: any): Promise; } /** @@ -893,7 +898,7 @@ declare namespace Parse { function define(name: string, func?: (request: FunctionRequest, response: FunctionResponse) => void): void; function httpRequest(options: HTTPOptions): Promise; function job(name: string, func?: (request: JobRequest, status: JobStatus) => void): HttpResponse; - function run(name: string, data?: any, options?: RunOptions): Promise; + function run(name: string, data?: any, options?: RunOptions): Promise; function useMasterKey(): void; interface RunOptions extends SuccessFailureOptions, ScopeOptions { } @@ -1064,7 +1069,7 @@ declare namespace Parse { push_time?: Date; expiration_time?: Date; expiration_interval?: number; - where?: Query; + where?: Query; data?: any; alert?: string; badge?: string; diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 7e6c163913..91f3f2cc02 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -37,6 +37,8 @@ function test_object() { var game = new Game(); + game.fetch((g: Game) => {}); + // Create a new instance of that class. var gameScore = new GameScore(); @@ -212,6 +214,10 @@ function test_analytics() { Parse.Analytics.track('error', { code: codeString }) } +function test_relation() { + new Parse.User().relation("games").query().find().then((g: Game[]) => {}); +} + function test_user_acl_roles() { var user = new Parse.User(); @@ -238,11 +244,12 @@ function test_user_acl_roles() { var game = new Game(); game.set("score", new GameScore()); game.setACL(new Parse.ACL(Parse.User.current())); - game.save(); + game.save().then((game: Game) => { + }); var groupACL = new Parse.ACL(); - var userList: Parse.User[] = [Parse.User.current()]; + var userList: Parse.User[] = [Parse.User.current()!]; // userList is an array with the users we are sending this message to. for (var i = 0; i < userList.length; i++) { groupACL.setReadAccess(userList[i], true); @@ -261,7 +268,7 @@ function test_user_acl_roles() { // By specifying no write privileges for the ACL, we can ensure the role cannot be altered. var role = new Parse.Role("Administrator", groupACL); - role.getUsers().add(role); + role.getUsers().add(userList[0]); role.getRoles().add(role); role.save(); @@ -292,7 +299,7 @@ function test_facebook_util() { } }); - var user = Parse.User.current(); + var user = Parse.User.current()!; if (!Parse.FacebookUtils.isLinked(user)) { Parse.FacebookUtils.link(user, null, { @@ -342,7 +349,7 @@ function test_geo_points() { var point = new Parse.GeoPoint({latitude: 40.0, longitude: -30.0}); - var userObject = Parse.User.current(); + var userObject = Parse.User.current()!; // User's location var userGeoPoint = userObject.get("location"); @@ -357,8 +364,10 @@ function test_geo_points() { var southwestOfSF = new Parse.GeoPoint(37.708813, -122.526398); var northeastOfSF = new Parse.GeoPoint(37.822802, -122.373962); - var query = new Parse.Query(PlaceObject); - query.withinGeoBox("location", southwestOfSF, northeastOfSF); + var query2 = new Parse.Query(PlaceObject); + query2.withinGeoBox("location", southwestOfSF, northeastOfSF); + + var query3 = new Parse.Query("PlaceObject").find().then((o: Parse.Object[]) => {}); } function test_push() { diff --git a/types/parse/tsconfig.json b/types/parse/tsconfig.json index 634ca903ac..5fecdb4dd5 100644 --- a/types/parse/tsconfig.json +++ b/types/parse/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -20,4 +20,4 @@ "index.d.ts", "parse-tests.ts" ] -} \ No newline at end of file +} From 2255a847d54d239da41f44382ee57b66fb2a1aa8 Mon Sep 17 00:00:00 2001 From: David Poetzsch-Heffter Date: Mon, 10 Apr 2017 22:40:44 +0200 Subject: [PATCH 2/7] more fixes --- types/parse/index.d.ts | 2 +- types/parse/parse-tests.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index c3bfa231d9..564114a082 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -361,7 +361,7 @@ declare namespace Parse { previousAttributes(): any; relation(attr: string): Relation; remove(attr: string, item: any): any; - save(attrs?: { [key: string]: any }, options?: Object.SaveOptions): Promise; + save(attrs?: { [key: string]: any } | null, options?: Object.SaveOptions): Promise; save(key: string, value: any, options?: Object.SaveOptions): Promise; set(key: string, value: any, options?: Object.SetOptions): boolean; setACL(acl: ACL, options?: SuccessFailureOptions): boolean; diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 91f3f2cc02..36dc7cb334 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -244,8 +244,8 @@ function test_user_acl_roles() { var game = new Game(); game.set("score", new GameScore()); game.setACL(new Parse.ACL(Parse.User.current())); - game.save().then((game: Game) => { - }); + game.save().then((game: Game) => {}); + game.save(null, { useMasterKey: true }); var groupACL = new Parse.ACL(); From e3e90790cf6fd0ccb0e480043377b3557c7aa79a Mon Sep 17 00:00:00 2001 From: David Poetzsch-Heffter Date: Tue, 11 Apr 2017 01:13:35 +0200 Subject: [PATCH 3/7] fixes --- types/parse/index.d.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 564114a082..72f494804b 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -82,7 +82,7 @@ declare namespace Parse { class Promise implements IPromise { static as(resolvedValue: U): Promise; - static error(error: U): Promise; + static error(error: any): Promise; static is(possiblePromise: any): Boolean; static when(promises: IPromise[]): Promise; static when(...promises: IPromise[]): Promise; @@ -285,10 +285,6 @@ declare namespace Parse { remove(object: T): void; } - interface ObjectConstructor { - new (options?: any): T; - } - /** * Creates a new model with defined attributes. A client id (cid) is * automatically generated and assigned for you. @@ -330,12 +326,12 @@ declare namespace Parse { constructor(attributes?: string[], options?: any); static extend(className: string, protoProps?: any, classProps?: any): any; - static fetchAll(list: T[], options: SuccessFailureOptions): Promise; - static fetchAllIfNeeded(list: T[], options: SuccessFailureOptions): Promise; - static destroyAll(list: T[], options?: Object.DestroyAllOptions): Promise; + static fetchAll(list: T[], options: SuccessFailureOptions): Promise; + static fetchAllIfNeeded(list: T[], options: SuccessFailureOptions): Promise; + static destroyAll(list: T[], options?: Object.DestroyAllOptions): Promise; static saveAll(list: T[], options?: Object.SaveAllOptions): Promise; - static registerSubclass(className: string, clazz: ObjectConstructor): void; + static registerSubclass(className: string, clazz: new (options?: any) => T): void; initialize(): void; add(attr: string, item: any): Object; @@ -581,7 +577,7 @@ declare namespace Parse { className: string; constructor(objectClass: string); - constructor(objectClass: ObjectConstructor); + constructor(objectClass: new(...args: any[]) => T); static or(...var_args: Query[]): Query; @@ -740,7 +736,7 @@ declare namespace Parse { isCurrent(): boolean; getEmail(): string | undefined; - setEmail(email: string, options: SuccessFailureOptions): boolean; + setEmail(email: string, options?: SuccessFailureOptions): boolean; getUsername(): string | undefined; setUsername(username: string, options?: SuccessFailureOptions): boolean; @@ -868,8 +864,8 @@ declare namespace Parse { } interface FunctionResponse { - success?: (response: any) => void; - error?: (response: any) => void; + success: (response: any) => void; + error: (response: any) => void; } interface Cookie { @@ -888,7 +884,7 @@ declare namespace Parse { interface BeforeDeleteResponse extends FunctionResponse {} interface BeforeSaveRequest extends SaveRequest {} interface BeforeSaveResponse extends FunctionResponse { - success?: () => void; + success: () => void; } function afterDelete(arg1: any, func?: (request: AfterDeleteRequest) => void): void; @@ -909,7 +905,7 @@ declare namespace Parse { * import Buffer = require("buffer").Buffer; */ var HTTPOptions: new () => HTTPOptions; - interface HTTPOptions extends FunctionResponse { + interface HTTPOptions { /** * The body of the request. * If it is a JSON object, then the Content-Type set in the headers must be application/x-www-form-urlencoded or application/json. @@ -939,6 +935,9 @@ declare namespace Parse { * The url to send the request to. */ url: string; + + success?: (response: any) => void; + error?: (response: any) => void; } } From 900f3f43b11afb8c817be9a012e4951d27957cd9 Mon Sep 17 00:00:00 2001 From: David Poetzsch-Heffter Date: Tue, 11 Apr 2017 12:57:45 +0200 Subject: [PATCH 4/7] improved sub classing of parse objects --- types/parse/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 72f494804b..d61e47ab9e 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -334,18 +334,18 @@ declare namespace Parse { static registerSubclass(className: string, clazz: new (options?: any) => T): void; initialize(): void; - add(attr: string, item: any): Object; + add(attr: string, item: any): this; addUnique(attr: string, item: any): any; - change(options: any): Object; + change(options: any): this; changedAttributes(diff: any): boolean; clear(options: any): any; - clone(): Object; - destroy(options?: Object.DestroyOptions): Promise; + clone(): this; + destroy(options?: Object.DestroyOptions): Promise; dirty(attr: String): boolean; dirtyKeys(): string[]; escape(attr: string): string; existed(): boolean; - fetch(options?: Object.FetchOptions): Promise; + fetch(options?: Object.FetchOptions): Promise; get(attr: string): any | undefined; getACL(): ACL | undefined; has(attr: string): boolean; @@ -355,10 +355,10 @@ declare namespace Parse { op(attr: string): any; previous(attr: string): any; previousAttributes(): any; - relation(attr: string): Relation; + relation(attr: string): Relation; remove(attr: string, item: any): any; - save(attrs?: { [key: string]: any } | null, options?: Object.SaveOptions): Promise; - save(key: string, value: any, options?: Object.SaveOptions): Promise; + save(attrs?: { [key: string]: any } | null, options?: Object.SaveOptions): Promise; + save(key: string, value: any, options?: Object.SaveOptions): Promise; set(key: string, value: any, options?: Object.SetOptions): boolean; setACL(acl: ACL, options?: SuccessFailureOptions): boolean; unset(attr: string, options?: any): any; From 2c280645150c81e10f9b0f010f26ae65afebbb41 Mon Sep 17 00:00:00 2001 From: David Poetzsch-Heffter Date: Tue, 11 Apr 2017 13:16:40 +0200 Subject: [PATCH 5/7] reverting some changes for now because they cause incompatibilities with existing code bases These changes should be discussed in a separate PR and might need to wait for default generic type arguments (typescript 2.3) --- types/parse/index.d.ts | 110 ++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index d61e47ab9e..1a008c50cd 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -267,22 +267,22 @@ declare namespace Parse { * A class that is used to access all of the children of a many-to-many relationship. * Each instance of Parse.Relation is associated with a particular parent object and key. */ - class Relation extends BaseObject { + class Relation extends BaseObject { - parent: S; + parent: Object; key: string; targetClassName: string; - constructor(parent?: S, key?: string); + constructor(parent?: Object, key?: string); //Adds a Parse.Object or an array of Parse.Objects to the relation. - add(object: T): void; + add(object: Object): void; // Returns a Parse.Query that is limited to objects in this relation. - query(): Query; + query(): Query; // Removes a Parse.Object or an array of Parse.Objects from this relation. - remove(object: T): void; + remove(object: Object): void; } /** @@ -355,7 +355,7 @@ declare namespace Parse { op(attr: string): any; previous(attr: string): any; previousAttributes(): any; - relation(attr: string): Relation; + relation(attr: string): Relation; remove(attr: string, item: any): any; save(attrs?: { [key: string]: any } | null, options?: Object.SaveOptions): Promise; save(key: string, value: any, options?: Object.SaveOptions): Promise; @@ -429,7 +429,7 @@ declare namespace Parse { model: Object; models: Object[]; - query: Query; + query: Query; comparator: (object: Object) => any; constructor(models?: Object[], options?: Collection.Options); @@ -454,7 +454,7 @@ declare namespace Parse { namespace Collection { interface Options { model?: Object; - query?: Query; + query?: Query; comparator?: string; } @@ -571,59 +571,59 @@ declare namespace Parse { * } * });

*/ - class Query extends BaseObject { + class Query extends BaseObject { objectClass: any; className: string; constructor(objectClass: string); - constructor(objectClass: new(...args: any[]) => T); + constructor(objectClass: new(...args: any[]) => Object); - static or(...var_args: Query[]): Query; + static or(...var_args: Query[]): Query; - addAscending(key: string): Query; - addAscending(key: string[]): Query; - addDescending(key: string): Query; - addDescending(key: string[]): Query; - ascending(key: string): Query; - ascending(key: string[]): Query; + addAscending(key: string): Query; + addAscending(key: string[]): Query; + addDescending(key: string): Query; + addDescending(key: string[]): Query; + ascending(key: string): Query; + ascending(key: string[]): Query; collection(items?: Object[], options?: Collection.Options): Collection; - containedIn(key: string, values: any[]): Query; - contains(key: string, substring: string): Query; - containsAll(key: string, values: any[]): Query; + containedIn(key: string, values: any[]): Query; + contains(key: string, substring: string): Query; + containsAll(key: string, values: any[]): Query; count(options?: Query.CountOptions): Promise; - descending(key: string): Query; - descending(key: string[]): Query; - doesNotExist(key: string): Query; - doesNotMatchKeyInQuery(key: string, queryKey: string, query: Query): Query; - doesNotMatchQuery(key: string, query: Query): Query; + descending(key: string): Query; + descending(key: string[]): Query; + doesNotExist(key: string): Query; + doesNotMatchKeyInQuery(key: string, queryKey: string, query: Query): Query; + doesNotMatchQuery(key: string, query: Query): Query; each(callback: Function, options?: Query.EachOptions): Promise; - endsWith(key: string, suffix: string): Query; - equalTo(key: string, value: any): Query; - exists(key: string): Query; - find(options?: Query.FindOptions): Promise; - first(options?: Query.FirstOptions): Promise; - get(objectId: string, options?: Query.GetOptions): Promise; - greaterThan(key: string, value: any): Query; - greaterThanOrEqualTo(key: string, value: any): Query; - include(key: string): Query; - include(keys: string[]): Query; - lessThan(key: string, value: any): Query; - lessThanOrEqualTo(key: string, value: any): Query; - limit(n: number): Query; - matches(key: string, regex: RegExp, modifiers: any): Query; - matchesKeyInQuery(key: string, queryKey: string, query: Query): Query; - matchesQuery(key: string, query: Query): Query; - near(key: string, point: GeoPoint): Query; - notContainedIn(key: string, values: any[]): Query; - notEqualTo(key: string, value: any): Query; - select(...keys: string[]): Query; - skip(n: number): Query; - startsWith(key: string, prefix: string): Query; - withinGeoBox(key: string, southwest: GeoPoint, northeast: GeoPoint): Query; - withinKilometers(key: string, point: GeoPoint, maxDistance: number): Query; - withinMiles(key: string, point: GeoPoint, maxDistance: number): Query; - withinRadians(key: string, point: GeoPoint, maxDistance: number): Query; + endsWith(key: string, suffix: string): Query; + equalTo(key: string, value: any): Query; + exists(key: string): Query; + find(options?: Query.FindOptions): Promise; + first(options?: Query.FirstOptions): Promise; + get(objectId: string, options?: Query.GetOptions): Promise; + greaterThan(key: string, value: any): Query; + greaterThanOrEqualTo(key: string, value: any): Query; + include(key: string): Query; + include(keys: string[]): Query; + lessThan(key: string, value: any): Query; + lessThanOrEqualTo(key: string, value: any): Query; + limit(n: number): Query; + matches(key: string, regex: RegExp, modifiers: any): Query; + matchesKeyInQuery(key: string, queryKey: string, query: Query): Query; + matchesQuery(key: string, query: Query): Query; + near(key: string, point: GeoPoint): Query; + notContainedIn(key: string, values: any[]): Query; + notEqualTo(key: string, value: any): Query; + select(...keys: string[]): Query; + skip(n: number): Query; + startsWith(key: string, prefix: string): Query; + withinGeoBox(key: string, southwest: GeoPoint, northeast: GeoPoint): Query; + withinKilometers(key: string, point: GeoPoint, maxDistance: number): Query; + withinMiles(key: string, point: GeoPoint, maxDistance: number): Query; + withinRadians(key: string, point: GeoPoint, maxDistance: number): Query; } namespace Query { @@ -651,8 +651,8 @@ declare namespace Parse { constructor(name: string, acl: ACL); - getRoles(): Relation; - getUsers(): Relation; + getRoles(): Relation; + getUsers(): Relation; getName(): string; setName(name: string, options?: SuccessFailureOptions): any; } @@ -1068,7 +1068,7 @@ declare namespace Parse { push_time?: Date; expiration_time?: Date; expiration_interval?: number; - where?: Query; + where?: Query; data?: any; alert?: string; badge?: string; From df62032b2f7f58250a38ff10a6cf0eaf9427d98f Mon Sep 17 00:00:00 2001 From: David Poetzsch-Heffter Date: Tue, 11 Apr 2017 13:24:48 +0200 Subject: [PATCH 6/7] updated version number --- types/parse/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 1a008c50cd..2f5b70698b 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Parse v1.2.19 +// Type definitions for parse v1.9.2 // Project: https://parse.com/ // Definitions by: Ullisen Media Group , David Poetzsch-Heffter // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 3535b5430cd3b29d49b1c386f6983d84b47c4273 Mon Sep 17 00:00:00 2001 From: David Poetzsch-Heffter Date: Tue, 11 Apr 2017 14:33:46 +0200 Subject: [PATCH 7/7] improved user sub classing --- types/parse/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 2f5b70698b..e839515d79 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -730,8 +730,8 @@ declare namespace Parse { static requestPasswordReset(email: string, options?: SuccessFailureOptions): Promise; static extend(protoProps?: any, classProps?: any): any; - signUp(attrs: any, options?: SuccessFailureOptions): Promise; - logIn(options?: SuccessFailureOptions): Promise; + signUp(attrs: any, options?: SuccessFailureOptions): Promise; + logIn(options?: SuccessFailureOptions): Promise; authenticated(): boolean; isCurrent(): boolean;