diff --git a/parse/parse-tests.ts b/parse/parse-tests.ts index 49b2e62b2..c7cc6ff49 100644 --- a/parse/parse-tests.ts +++ b/parse/parse-tests.ts @@ -54,52 +54,6 @@ function test_object() { gameScore.addUnique("skills", "kungfu"); game.set("gameScore", gameScore); - - game.save(null, { - success: (game) => { - // Execute any logic that should take place after the object is saved. - console.log('New object created with objectId: ' + game.id); - }, - error: (game, error) => { - // Execute any logic that should take place if the save fails. - // error is a Parse.Error with an error code and description. - console.log('Fa iled to create new object, with error code: ' + error.message); - } - }).then( - - (response) => { - - console.log(response); - }, - (error) => { - - console.log(error); - } - ); - - game.fetch().then( - - (response) => { - - console.log(response); - }, - (error) => { - - console.log(error); - } - ); - - game.destroy().then( - - (response) => { - - console.log(response); - }, - (error) => { - - console.log(error); - } - ); } function test_query() { @@ -161,38 +115,6 @@ function test_query() { query.include(["score.team"]); var testQuery = Parse.Query.or(query, query); - - query.count().then( - (object) => { - - }, - (error) => { - console.log("Error: " + error.code + " " + error.message); - } - ); - - query.find({ - success: (results) => { - alert("Successfully retrieved " + results.length + " scores."); - // Do something with the returned Parse.Object values - for (var i = 0; i < results.length; i++) { - var object = results[i]; - console.log(object.id + ' - ' + object.get('playerName')); - } - }, - error: (error) => { - alert("Error: " + error.code + " " + error.message); - } - }); - - query.first().then( - (object) => { - - }, - (error) => { - console.log("Error: " + error.code + " " + error.message); - } - ); } class TestCollection extends Parse.Collection { @@ -300,25 +222,6 @@ function test_user_acl_roles() { // other fields can be set just like with Parse.Object user.set("phone", "415-392-0202"); - user.signUp(null, { - success: function(user) { - // Hooray! Let them use the app now. - }, - error: function(user, error) { - // Show the error message somewhere and let the user try again. - alert("Error: " + error.code + " " + error.message); - } - }); - - Parse.User.logIn("myname", "mypass").then( - (data) => { - - }, - (error) => { - console.log("Error: " + error.code + " " + error.message); - } - ); - var currentUser = Parse.User.current(); if (currentUser) { // do stuff with the user @@ -339,7 +242,7 @@ function test_user_acl_roles() { var groupACL = new Parse.ACL(); - var userList = []; + 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); @@ -375,14 +278,14 @@ function test_facebook_util() { }); Parse.FacebookUtils.logIn(null, { - success: (user) => { + success: (user: Parse.User) => { if (!user.existed()) { alert("User signed up and logged in through Facebook!"); } else { alert("User logged in through Facebook!"); } }, - error: (user, error) => { + error: (user: Parse.User, error: any) => { alert("User cancelled the Facebook login or did not fully authorize."); } }); @@ -391,17 +294,17 @@ function test_facebook_util() { if (!Parse.FacebookUtils.isLinked(user)) { Parse.FacebookUtils.link(user, null, { - success: (user) => { + success: (user: any) => { alert("Woohoo, user logged in with Facebook!"); }, - error: (user, error) => { + error: (user: any, error: any) => { alert("User cancelled the Facebook login or did not fully authorize."); } }); } Parse.FacebookUtils.unlink(user, { - success: (user) => { + success: (user: Parse.User) => { alert("The user is no longer associated with their Facebook account."); } }); @@ -410,10 +313,10 @@ function test_facebook_util() { function test_cloud_functions() { Parse.Cloud.run('hello', {}, { - success: (result) => { + success: (result: any) => { // result }, - error: (error) => { + error: (error: any) => { } }); @@ -448,23 +351,12 @@ function test_geo_points() { query.near("location", userGeoPoint); // Limit what could be a lot of points. query.limit(10); - // Final list of objects - query.find({ - success: (placesObjects) => { - } - }); - 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); - query.find({ - success: function(place) { - - } - }); } function test_push() { @@ -478,7 +370,7 @@ function test_push() { success: () => { // Push was successful }, - error: (error) => { + error: (error: any) => { // Handle error } }); @@ -495,7 +387,7 @@ function test_push() { success: function() { // Push was successful }, - error: function(error) { + error: function(error: any) { // Handle error } }); diff --git a/parse/parse.d.ts b/parse/parse.d.ts index 697e3bf87..4f179eb91 100644 --- a/parse/parse.d.ts +++ b/parse/parse.d.ts @@ -1,6 +1,6 @@ // Type definitions for Parse v1.2.19 // Project: https://parse.com/ -// Definitions by: Ullisen Media Group, LLC <[http://ullisenmedia.com]> +// Definitions by: Ullisen Media Group LLC // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -136,30 +136,30 @@ declare module Parse { constructor(arg1?: any); - setPublicReadAccess(allowed: boolean); + setPublicReadAccess(allowed: boolean): void; getPublicReadAccess(): boolean; - setPublicWriteAccess(allowed: boolean); + setPublicWriteAccess(allowed: boolean): void; getPublicWriteAccess(): boolean; - setReadAccess(userId: User, allowed: boolean); + setReadAccess(userId: User, allowed: boolean): void; getReadAccess(userId: User): boolean; - setReadAccess(userId: string, allowed: boolean); + setReadAccess(userId: string, allowed: boolean): void; getReadAccess(userId: string): boolean; - setRoleReadAccess(role: Role, allowed: boolean); - setRoleReadAccess(role: string, allowed: boolean); + setRoleReadAccess(role: Role, allowed: boolean): void; + setRoleReadAccess(role: string, allowed: boolean): void; getRoleReadAccess(role: Role): boolean; getRoleReadAccess(role: string): boolean; - setRoleWriteAccess(role: Role, allowed: boolean); - setRoleWriteAccess(role: string, allowed: boolean); + setRoleWriteAccess(role: Role, allowed: boolean): void; + setRoleWriteAccess(role: string, allowed: boolean): void; getRoleWriteAccess(role: Role): boolean; getRoleWriteAccess(role: string): boolean; - setWriteAccess(userId: User, allowed: boolean); - setWriteAccess(userId: string, allowed: boolean); + setWriteAccess(userId: User, allowed: boolean): void; + setWriteAccess(userId: string, allowed: boolean): void; getWriteAccess(userId: User): boolean; getWriteAccess(userId: string): boolean; } @@ -199,7 +199,7 @@ declare module Parse { constructor(name: string, data: any, type?: string); name(): string; url(): string; - save(options?: ParseDefaultOptions); + save(options?: ParseDefaultOptions): Promise; } @@ -335,18 +335,18 @@ declare module Parse { static fetchAll(list: Object[], options: ParseDefaultOptions): Promise; static fetchAllIfNeeded(list: Object[], options: ParseDefaultOptions): Promise; - initialize(); - add(attr: string, item: any); - addUnique(attr: string, item: any); - change(options: any); - changedAttributes(diff: any): any; + initialize(): void; + add(attr: string, item: any): Object; + addUnique(attr: string, item: any): any; + change(options: any): Object; + changedAttributes(diff: any): boolean; clear(options: any): any; clone(): Object; destroy(options?: ParseDefaultOptions): Promise; destroyAll(list: Object[], options?: ParseDefaultOptions): Promise; dirty(attr: String): boolean; dirtyKeys(): string[]; - escape(attr: string); + escape(attr: string): string; existed(): boolean; fetch(options?: ParseDefaultOptions): Promise; get(attr: string): any; @@ -424,7 +424,7 @@ declare module Parse { static extend(instanceProps: any, classProps: any): any; initialize(): void; - add(models: any[], options?: CollectionAddOptions); + add(models: any[], options?: CollectionAddOptions): Collection; at(index: number): Object; chain(): _Chain>; fetch(options?: ParseDefaultOptions): Promise; @@ -464,17 +464,17 @@ declare module Parse { */ class Events { - static off(events: string[], callback?: Function, context?: any); - static on(events: string[], callback?: Function, context?: any); - static trigger(events: string[]); - static bind(); - static unbind(); + static off(events: string[], callback?: Function, context?: any): Events; + static on(events: string[], callback?: Function, context?: any): Events; + static trigger(events: string[]): Events; + static bind(): Events; + static unbind(): Events; - on(eventName: string, callback?: Function, context?: any): any; - off(eventName?: string, callback?: Function, context?: any): any; - trigger(eventName: string, ...args: any[]): any; - bind(eventName: string, callback: Function, context?: any): any; - unbind(eventName?: string, callback?: Function, context?: any): any; + on(eventName: string, callback?: Function, context?: any): Events; + off(eventName?: string, callback?: Function, 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; } @@ -608,7 +608,7 @@ declare module Parse { getRoles(): Relation; getUsers(): Relation; getName(): string; - setName(name: string, options?: ParseDefaultOptions); + setName(name: string, options?: ParseDefaultOptions): any; } /** @@ -627,7 +627,6 @@ declare module Parse { routes: any[]; constructor(options?: RouterOptions); - static extend(instanceProps: any, classProps: any): any; initialize(): void; @@ -669,7 +668,6 @@ declare module Parse { setUsername(username: string, options?: ParseDefaultOptions): boolean; setPassword(password: string, options?: ParseDefaultOptions): boolean; - getSessionToken(): string; } @@ -724,7 +722,7 @@ declare module Parse { */ module FacebookUtils { - function init(options?: any); + function init(options?: any): void; function isLinked(user: User): boolean; function link(user: User, permissions: any, options?: ParseDefaultOptions): void; function logIn(permissions: any, options?: ParseDefaultOptions): void; @@ -929,7 +927,7 @@ declare module Parse { * @param {String} javaScriptKey Your Parse JavaScript Key. * @param {String} masterKey (optional) Your Parse Master Key. (Node.js only!) */ - function initialize(applicationId: string, javaScriptKey: string, masterKey?: string); + function initialize(applicationId: string, javaScriptKey: string, masterKey?: string): void; }