diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index dacfb9e48..9f6b2353a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,6 +23,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: npm ci
+ # - name: Build types (enable when full typescript support)
+ # run: npm run build:types
- name: Check types
run: npm run test:types
build:
diff --git a/package.json b/package.json
index 45c06dd47..5d37949fd 100644
--- a/package.json
+++ b/package.json
@@ -23,11 +23,13 @@
"lib/",
"LICENSE",
"NOTICE",
- "README.md"
+ "README.md",
+ "types/index.d.ts"
],
"browser": {
"react-native": false
},
+ "types": "types",
"dependencies": {
"@babel/runtime-corejs3": "7.22.6",
"idb-keyval": "6.2.1",
diff --git a/src/ParseQuery.js b/src/ParseQuery.js
index f2e18b4d0..ebe56d845 100644
--- a/src/ParseQuery.js
+++ b/src/ParseQuery.js
@@ -1575,7 +1575,7 @@ class ParseQuery {
* @param {string} modifiers The regular expression mode.
* @returns {Parse.Query} Returns the query, so you can chain this call.
*/
- startsWith(key: string, prefix: string, modifiers: string): ParseQuery {
+ startsWith(key: string, prefix: string, modifiers?: string): ParseQuery {
if (typeof prefix !== 'string') {
throw new Error('The value being searched for must be a string.');
}
diff --git a/src/ParseSession.ts b/src/ParseSession.ts
index 51b001742..fa1782d64 100644
--- a/src/ParseSession.ts
+++ b/src/ParseSession.ts
@@ -2,8 +2,6 @@ import CoreManager from './CoreManager';
import isRevocableSession from './isRevocableSession';
import ParseObject from './ParseObject';
import ParseUser from './ParseUser';
-
-import type { AttributeMap } from './ObjectStateMutations';
import type { RequestOptions, FullOptions } from './RESTController';
/**
diff --git a/tsconfig.json b/tsconfig.json
index 051477c29..73135762d 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -9,7 +9,6 @@
"allowJs": false
},
"files": [
- "src/Parse.ts",
- "src/ParseSession.ts"
+ "src/Parse.ts"
]
}
diff --git a/types/ParseObject.d.ts b/types/ParseObject.d.ts
index 09eb14634..6695dc8e9 100644
--- a/types/ParseObject.d.ts
+++ b/types/ParseObject.d.ts
@@ -567,7 +567,7 @@ declare class ParseObject {
* The only supported option is error
.
* @returns {(ParseObject|boolean)} true if the set succeeded.
*/
- set(key: mixed, value: mixed, options?: mixed): ParseObject | boolean;
+ set(key: mixed, value?: mixed, options?: mixed): ParseObject | boolean;
/**
* Remove an attribute from the model. This is a noop if the attribute doesn't
* exist.
@@ -783,7 +783,7 @@ declare class ParseObject {
* @returns {Promise} A promise that is fulfilled when the fetch
* completes.
*/
- fetchWithInclude(keys: String | Array>, options: RequestOptions): Promise;
+ fetchWithInclude(keys: String | Array>, options?: RequestOptions): Promise;
/**
* Saves this object to the server at some unspecified time in the future,
* even if Parse is currently inaccessible.
@@ -873,8 +873,8 @@ declare class ParseObject {
* completes.
*/
save(arg1?: string | {
- [attr: string]: mixed;
- }, arg2?: SaveOptions | mixed, arg3?: SaveOptions): Promise;
+ [attr: string]: object;
+ } | null, arg2?: SaveOptions | object, arg3?: SaveOptions): Promise;
/**
* Deletes this object from the server at some unspecified time in the future,
* even if Parse is currently inaccessible.
diff --git a/types/tests.ts b/types/tests.ts
index a275584e9..bd5d8bd7c 100644
--- a/types/tests.ts
+++ b/types/tests.ts
@@ -1,83 +1,83 @@
import Parse from './Parse';
// Parse is a global type, but it can also be imported
-// class GameScore extends Parse.Object {
-// constructor(options?: any) {
-// super('GameScore', options);
-// }
-// }
+class GameScore extends Parse.Object {
+ constructor(options?: any) {
+ super('GameScore', options);
+ }
+}
-// class Game extends Parse.Object {
-// constructor(options?: any) {
-// super('Game', options);
-// }
-// }
+class Game extends Parse.Object {
+ constructor(options?: any) {
+ super('Game', options);
+ }
+}
-// function test_config() {
-// Parse.Config.save({ foo: 'bar' }, { foo: true });
-// Parse.Config.get({ useMasterKey: true });
-// }
+function test_config() {
+ Parse.Config.save({ foo: 'bar' }, { foo: true });
+ Parse.Config.get({ useMasterKey: true });
+}
-// function test_object() {
-// const game = new Game();
-// game.save(null, {
-// useMasterKey: true,
-// sessionToken: 'sometoken',
-// cascadeSave: false,
-// }).then(result => result);
+function test_object() {
+ const game = new Game();
+ game.save(null, {
+ useMasterKey: true,
+ sessionToken: 'sometoken',
+ cascadeSave: false,
+ }).then(result => result);
-// if (!game.isNew()) {
+ if (!game.isNew()) {
-// }
+ }
-// if (game.toPointer().className !== 'Game') {
+ if (game.toPointer().className !== 'Game') {
-// }
+ }
-// game.fetch({});
+ game.fetch({});
-// // Create a new instance of that class.
-// const gameScore = new GameScore();
+ // Create a new instance of that class.
+ const gameScore = new GameScore();
-// gameScore.set('score', 1337);
-// gameScore.set('playerName', 'Sean Plott');
-// gameScore.set('cheatMode', false);
+ gameScore.set('score', 1337);
+ gameScore.set('playerName', 'Sean Plott');
+ gameScore.set('cheatMode', false);
-// // Setting attrs using object
-// gameScore.set({
-// level: '10',
-// difficult: 15,
-// });
+ // Setting attrs using object
+ gameScore.set({
+ level: '10',
+ difficult: 15,
+ });
-// const score = gameScore.get('score');
-// const playerName = gameScore.get('playerName');
-// const cheatMode = gameScore.get('cheatMode');
+ const score = gameScore.get('score');
+ const playerName = gameScore.get('playerName');
+ const cheatMode = gameScore.get('cheatMode');
-// gameScore.increment('score');
-// gameScore.addUnique('skills', 'flying');
-// gameScore.addUnique('skills', 'kungfu');
-// gameScore.addAll('skills', ['kungfu']);
-// gameScore.addAllUnique('skills', ['kungfu']);
-// gameScore.remove('skills', 'flying');
-// gameScore.removeAll('skills', ['kungFu']);
-// game.set('gameScore', gameScore);
+ gameScore.increment('score');
+ gameScore.addUnique('skills', 'flying');
+ gameScore.addUnique('skills', 'kungfu');
+ gameScore.addAll('skills', ['kungfu']);
+ gameScore.addAllUnique('skills', ['kungfu']);
+ gameScore.remove('skills', 'flying');
+ gameScore.removeAll('skills', ['kungFu']);
+ game.set('gameScore', gameScore);
-// const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true);
+ const gameCopy = Game.fromJSON(JSON.parse(JSON.stringify(game)), true);
-// const object = new Parse.Object('TestObject');
-// object.equals(gameScore);
-// object.fetchWithInclude(['key1', 'key2']);
-// }
+ const object = new Parse.Object('TestObject');
+ object.equals(gameScore);
+ object.fetchWithInclude(['key1', 'key2']);
+}
-// function test_errors() {
-// try {
-// throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds');
-// } catch (error) {
-// if (error.code !== 1) {
+function test_errors() {
+ try {
+ throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds');
+ } catch (error) {
+ if (error.code !== 1) {
-// }
-// }
-// }
+ }
+ }
+}
// function test_query() {
// const gameScore = new GameScore();
@@ -2053,21 +2053,21 @@ import Parse from './Parse';
// }
// }
-function testSession() {
- function testConstructor() {
- // $ExpectType ParseSession
- new Parse.Session();
+// function testSession() {
+// function testConstructor() {
+// // $ExpectType ParseSession
+// new Parse.Session();
- // $ExpectType ParseSession
- new Parse.Session({ example: 100 });
+// // $ExpectType ParseSession
+// new Parse.Session({ example: 100 });
- // @ts-expect-error
- new Parse.Session<{ example: number }>();
+// // @ts-expect-error
+// new Parse.Session<{ example: number }>();
- // @ts-expect-error
- new Parse.Session<{ example: number }>({ example: 'hello' });
- }
-}
+// // @ts-expect-error
+// new Parse.Session<{ example: number }>({ example: 'hello' });
+// }
+// }
// function testUser() {
// function testConstructor() {