Skip to content

Commit b59b111

Browse files
committed
merge
add tests Update ParseSession.js Update ci.yml
1 parent 41a41b4 commit b59b111

File tree

7 files changed

+83
-82
lines changed

7 files changed

+83
-82
lines changed

Diff for: .github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
steps:
2424
- uses: actions/checkout@v3
2525
- run: npm ci
26+
# - name: Build types (enable when full typescript support)
27+
# run: npm run build:types
2628
- name: Check types
2729
run: npm run test:types
2830
build:

Diff for: package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
"lib/",
2424
"LICENSE",
2525
"NOTICE",
26-
"README.md"
26+
"README.md",
27+
"types/index.d.ts"
2728
],
2829
"browser": {
2930
"react-native": false
3031
},
32+
"types": "types",
3133
"dependencies": {
3234
"@babel/runtime-corejs3": "7.22.6",
3335
"idb-keyval": "6.2.1",

Diff for: src/ParseQuery.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ class ParseQuery {
15751575
* @param {string} modifiers The regular expression mode.
15761576
* @returns {Parse.Query} Returns the query, so you can chain this call.
15771577
*/
1578-
startsWith(key: string, prefix: string, modifiers: string): ParseQuery {
1578+
startsWith(key: string, prefix: string, modifiers?: string): ParseQuery {
15791579
if (typeof prefix !== 'string') {
15801580
throw new Error('The value being searched for must be a string.');
15811581
}

Diff for: src/ParseSession.ts

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import CoreManager from './CoreManager';
22
import isRevocableSession from './isRevocableSession';
33
import ParseObject from './ParseObject';
44
import ParseUser from './ParseUser';
5-
6-
import type { AttributeMap } from './ObjectStateMutations';
75
import type { RequestOptions, FullOptions } from './RESTController';
86

97
/**

Diff for: tsconfig.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"allowJs": false
1010
},
1111
"files": [
12-
"src/Parse.ts",
13-
"src/ParseSession.ts"
12+
"src/Parse.ts"
1413
]
1514
}

Diff for: types/ParseObject.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ declare class ParseObject {
567567
* The only supported option is <code>error</code>.
568568
* @returns {(ParseObject|boolean)} true if the set succeeded.
569569
*/
570-
set(key: mixed, value: mixed, options?: mixed): ParseObject | boolean;
570+
set(key: mixed, value?: mixed, options?: mixed): ParseObject | boolean;
571571
/**
572572
* Remove an attribute from the model. This is a noop if the attribute doesn't
573573
* exist.
@@ -783,7 +783,7 @@ declare class ParseObject {
783783
* @returns {Promise} A promise that is fulfilled when the fetch
784784
* completes.
785785
*/
786-
fetchWithInclude(keys: String | Array<string | Array<string>>, options: RequestOptions): Promise<any>;
786+
fetchWithInclude(keys: String | Array<string | Array<string>>, options?: RequestOptions): Promise<any>;
787787
/**
788788
* Saves this object to the server at some unspecified time in the future,
789789
* even if Parse is currently inaccessible.
@@ -873,8 +873,8 @@ declare class ParseObject {
873873
* completes.
874874
*/
875875
save(arg1?: string | {
876-
[attr: string]: mixed;
877-
}, arg2?: SaveOptions | mixed, arg3?: SaveOptions): Promise<any>;
876+
[attr: string]: object;
877+
} | null, arg2?: SaveOptions | object, arg3?: SaveOptions): Promise<any>;
878878
/**
879879
* Deletes this object from the server at some unspecified time in the future,
880880
* even if Parse is currently inaccessible.

Diff for: types/tests.ts

+72-72
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,83 @@
11
import Parse from './Parse';
22
// Parse is a global type, but it can also be imported
33

4-
// class GameScore extends Parse.Object {
5-
// constructor(options?: any) {
6-
// super('GameScore', options);
7-
// }
8-
// }
4+
class GameScore extends Parse.Object {
5+
constructor(options?: any) {
6+
super('GameScore', options);
7+
}
8+
}
99

10-
// class Game extends Parse.Object {
11-
// constructor(options?: any) {
12-
// super('Game', options);
13-
// }
14-
// }
10+
class Game extends Parse.Object {
11+
constructor(options?: any) {
12+
super('Game', options);
13+
}
14+
}
1515

16-
// function test_config() {
17-
// Parse.Config.save({ foo: 'bar' }, { foo: true });
18-
// Parse.Config.get({ useMasterKey: true });
19-
// }
16+
function test_config() {
17+
Parse.Config.save({ foo: 'bar' }, { foo: true });
18+
Parse.Config.get({ useMasterKey: true });
19+
}
2020

21-
// function test_object() {
22-
// const game = new Game();
23-
// game.save(null, {
24-
// useMasterKey: true,
25-
// sessionToken: 'sometoken',
26-
// cascadeSave: false,
27-
// }).then(result => result);
21+
function test_object() {
22+
const game = new Game();
23+
game.save(null, {
24+
useMasterKey: true,
25+
sessionToken: 'sometoken',
26+
cascadeSave: false,
27+
}).then(result => result);
2828

29-
// if (!game.isNew()) {
29+
if (!game.isNew()) {
3030

31-
// }
31+
}
3232

33-
// if (game.toPointer().className !== 'Game') {
33+
if (game.toPointer().className !== 'Game') {
3434

35-
// }
35+
}
3636

37-
// game.fetch({});
37+
game.fetch({});
3838

39-
// // Create a new instance of that class.
40-
// const gameScore = new GameScore();
39+
// Create a new instance of that class.
40+
const gameScore = new GameScore();
4141

42-
// gameScore.set('score', 1337);
43-
// gameScore.set('playerName', 'Sean Plott');
44-
// gameScore.set('cheatMode', false);
42+
gameScore.set('score', 1337);
43+
gameScore.set('playerName', 'Sean Plott');
44+
gameScore.set('cheatMode', false);
4545

46-
// // Setting attrs using object
47-
// gameScore.set({
48-
// level: '10',
49-
// difficult: 15,
50-
// });
46+
// Setting attrs using object
47+
gameScore.set({
48+
level: '10',
49+
difficult: 15,
50+
});
5151

52-
// const score = gameScore.get('score');
53-
// const playerName = gameScore.get('playerName');
54-
// const cheatMode = gameScore.get('cheatMode');
52+
const score = gameScore.get('score');
53+
const playerName = gameScore.get('playerName');
54+
const cheatMode = gameScore.get('cheatMode');
5555

56-
// gameScore.increment('score');
57-
// gameScore.addUnique('skills', 'flying');
58-
// gameScore.addUnique('skills', 'kungfu');
59-
// gameScore.addAll('skills', ['kungfu']);
60-
// gameScore.addAllUnique('skills', ['kungfu']);
61-
// gameScore.remove('skills', 'flying');
62-
// gameScore.removeAll('skills', ['kungFu']);
63-
// game.set('gameScore', gameScore);
56+
gameScore.increment('score');
57+
gameScore.addUnique('skills', 'flying');
58+
gameScore.addUnique('skills', 'kungfu');
59+
gameScore.addAll('skills', ['kungfu']);
60+
gameScore.addAllUnique('skills', ['kungfu']);
61+
gameScore.remove('skills', 'flying');
62+
gameScore.removeAll('skills', ['kungFu']);
63+
game.set('gameScore', gameScore);
6464

65-
// const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true);
65+
const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true);
6666

67-
// const object = new Parse.Object('TestObject');
68-
// object.equals(gameScore);
69-
// object.fetchWithInclude(['key1', 'key2']);
70-
// }
67+
const object = new Parse.Object('TestObject');
68+
object.equals(gameScore);
69+
object.fetchWithInclude(['key1', 'key2']);
70+
}
7171

72-
// function test_errors() {
73-
// try {
74-
// throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds');
75-
// } catch (error) {
76-
// if (error.code !== 1) {
72+
function test_errors() {
73+
try {
74+
throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds');
75+
} catch (error) {
76+
if (error.code !== 1) {
7777

78-
// }
79-
// }
80-
// }
78+
}
79+
}
80+
}
8181

8282
// function test_query() {
8383
// const gameScore = new GameScore();
@@ -2053,21 +2053,21 @@ import Parse from './Parse';
20532053
// }
20542054
// }
20552055

2056-
function testSession() {
2057-
function testConstructor() {
2058-
// $ExpectType ParseSession
2059-
new Parse.Session();
2056+
// function testSession() {
2057+
// function testConstructor() {
2058+
// // $ExpectType ParseSession
2059+
// new Parse.Session();
20602060

2061-
// $ExpectType ParseSession
2062-
new Parse.Session({ example: 100 });
2061+
// // $ExpectType ParseSession
2062+
// new Parse.Session({ example: 100 });
20632063

2064-
// @ts-expect-error
2065-
new Parse.Session<{ example: number }>();
2064+
// // @ts-expect-error
2065+
// new Parse.Session<{ example: number }>();
20662066

2067-
// @ts-expect-error
2068-
new Parse.Session<{ example: number }>({ example: 'hello' });
2069-
}
2070-
}
2067+
// // @ts-expect-error
2068+
// new Parse.Session<{ example: number }>({ example: 'hello' });
2069+
// }
2070+
// }
20712071

20722072
// function testUser() {
20732073
// function testConstructor() {

0 commit comments

Comments
 (0)