Skip to content

Commit 31796f3

Browse files
authored
refactor: Remove Flow Type (#2145)
1 parent acd59aa commit 31796f3

33 files changed

+1258
-954
lines changed

.eslintrc.json

-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"extends": [
44
"eslint:recommended",
55
"plugin:jsdoc/recommended",
6-
"plugin:flowtype/recommended",
76
"plugin:@typescript-eslint/recommended"
87
],
98
"env": {
@@ -15,7 +14,6 @@
1514
"wx": true
1615
},
1716
"plugins": [
18-
"flowtype",
1917
"jsdoc",
2018
"@typescript-eslint"
2119
],
@@ -46,7 +44,6 @@
4644
"@typescript-eslint/no-explicit-any": "off",
4745
"@typescript-eslint/no-var-requires": "off",
4846
"@typescript-eslint/no-non-null-assertion": "off",
49-
"flowtype/no-types-missing-file-annotation": 0,
5047
"jsdoc/require-jsdoc": 0,
5148
"jsdoc/require-returns-description": 0,
5249
"jsdoc/require-param-description": 0,
@@ -59,15 +56,6 @@
5956
"allowExtraTrailingParamDocs": true
6057
}
6158
],
62-
"jsdoc/check-tag-names": [
63-
"error",
64-
{
65-
"definedTags": [
66-
"flow",
67-
"flow-weak"
68-
]
69-
}
70-
],
7159
"jsdoc/no-undefined-types": [
7260
"error",
7361
{

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Parse Community has a [responsible Vulnerability Disclosure Program](https://git
9898
## Coding Style
9999

100100
* Most importantly, match the existing code style as much as possible.
101-
* We use [Flow](http://flowtype.org/) and ES6 for this codebase. Use modern syntax whenever possible.
101+
* We use ES6 for this codebase. Use modern syntax whenever possible.
102102
* Keep lines within 80 characters.
103103
* Always end lines with semicolons.
104104

babel-jest.js

-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ module.exports = babelJest.createTransformer({
88
useBuiltIns: 'entry',
99
corejs: 3,
1010
}]],
11-
plugins: ['@babel/plugin-transform-flow-comments'],
1211
});

gulpfile.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ const PRESETS = {
3232
'react-native': ["@babel/preset-typescript", 'module:metro-react-native-babel-preset'],
3333
};
3434
const PLUGINS = {
35-
'browser': [transformRuntime, '@babel/plugin-transform-flow-comments', '@babel/plugin-proposal-class-properties', 'inline-package-json',
35+
'browser': [transformRuntime, '@babel/plugin-proposal-class-properties', 'inline-package-json',
3636
['transform-inline-environment-variables', {'exclude': ['SERVER_RENDERING']}]],
37-
'weapp': [transformRuntime, '@babel/plugin-transform-flow-comments', '@babel/plugin-proposal-class-properties', 'inline-package-json',
37+
'weapp': [transformRuntime, '@babel/plugin-proposal-class-properties', 'inline-package-json',
3838
['transform-inline-environment-variables', {'exclude': ['SERVER_RENDERING']}]],
39-
'node': ['@babel/plugin-transform-flow-comments', 'inline-package-json', 'transform-inline-environment-variables'],
40-
'react-native': ['@babel/plugin-transform-flow-comments', 'inline-package-json', 'transform-inline-environment-variables']
39+
'node': ['inline-package-json', 'transform-inline-environment-variables'],
40+
'react-native': ['inline-package-json', 'transform-inline-environment-variables']
4141
};
4242

4343
const DEV_HEADER = (

jsdoc-conf.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"babel": {
44
"babelrc": false,
55
"extensions": ["js", "ts", "jsx", "tsx"],
6-
"plugins": ["@babel/plugin-transform-flow-comments"],
76
"presets": ["@babel/preset-typescript"]
87
},
98
"source": {

package-lock.json

+1-72
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-3
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
"devDependencies": {
4040
"@babel/core": "7.22.0",
4141
"@babel/plugin-proposal-class-properties": "7.18.6",
42-
"@babel/plugin-transform-flow-comments": "7.22.5",
43-
"@babel/plugin-transform-flow-strip-types": "7.21.0",
4442
"@babel/plugin-transform-runtime": "7.21.4",
4543
"@babel/preset-env": "7.21.5",
4644
"@babel/preset-react": "7.22.5",
@@ -64,7 +62,6 @@
6462
"core-js": "3.30.2",
6563
"cross-env": "7.0.2",
6664
"eslint": "8.56.0",
67-
"eslint-plugin-flowtype": "8.0.3",
6865
"eslint-plugin-jsdoc": "48.2.5",
6966
"express": "4.18.2",
7067
"gulp": "4.0.2",

src/.flowconfig

-10
This file was deleted.

src/EventuallyQueue.js src/EventuallyQueue.ts

+13-19
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/**
2-
* https://github.com/francimedia/parse-js-local-storage
3-
*
4-
* @flow
5-
*/
6-
71
import CoreManager from './CoreManager';
82
import ParseError from './ParseError';
93
import ParseObject from './ParseObject';
@@ -27,9 +21,9 @@ type QueueObject = {
2721
type Queue = Array<QueueObject>;
2822

2923
const QUEUE_KEY = 'Parse/Eventually/Queue';
30-
let queueCache = [];
24+
let queueCache: QueueObject[] = [];
3125
let dirtyCache = true;
32-
let polling = undefined;
26+
let polling: ReturnType<typeof setInterval> | undefined = undefined;
3327

3428
/**
3529
* Provides utility functions to queue objects that will be
@@ -50,7 +44,7 @@ const EventuallyQueue = {
5044
* @static
5145
* @see Parse.Object#saveEventually
5246
*/
53-
save(object: ParseObject, serverOptions: SaveOptions = {}): Promise {
47+
save(object: ParseObject, serverOptions: SaveOptions = {}): Promise<void> {
5448
return this.enqueue('save', object, serverOptions);
5549
},
5650

@@ -65,7 +59,7 @@ const EventuallyQueue = {
6559
* @static
6660
* @see Parse.Object#destroyEventually
6761
*/
68-
destroy(object: ParseObject, serverOptions: RequestOptions = {}): Promise {
62+
destroy(object: ParseObject, serverOptions: RequestOptions = {}): Promise<void> {
6963
return this.enqueue('destroy', object, serverOptions);
7064
},
7165

@@ -99,7 +93,7 @@ const EventuallyQueue = {
9993
action: string,
10094
object: ParseObject,
10195
serverOptions: SaveOptions | RequestOptions
102-
): Promise {
96+
): Promise<void> {
10397
const queueData = await this.getQueue();
10498
const queueId = this.generateQueueId(action, object);
10599

@@ -127,7 +121,7 @@ const EventuallyQueue = {
127121
return this.setQueue(queueData);
128122
},
129123

130-
store(data) {
124+
store(data: QueueObject[]) {
131125
return Storage.setItemAsync(QUEUE_KEY, JSON.stringify(data));
132126
},
133127

@@ -140,10 +134,10 @@ const EventuallyQueue = {
140134
*
141135
* @function getQueue
142136
* @name Parse.EventuallyQueue.getQueue
143-
* @returns {Promise<Array>}
137+
* @returns {Promise<QueueObject[]>}
144138
* @static
145139
*/
146-
async getQueue(): Promise<Array> {
140+
async getQueue(): Promise<QueueObject[]> {
147141
if (dirtyCache) {
148142
queueCache = JSON.parse((await this.load()) || '[]');
149143
dirtyCache = false;
@@ -189,7 +183,7 @@ const EventuallyQueue = {
189183
* @returns {Promise} A promise that is fulfilled when queue is cleared.
190184
* @static
191185
*/
192-
clear(): Promise {
186+
clear(): Promise<void> {
193187
queueCache = [];
194188
return this.store([]);
195189
},
@@ -212,10 +206,10 @@ const EventuallyQueue = {
212206
*
213207
* @function length
214208
* @name Parse.EventuallyQueue.length
215-
* @returns {number}
209+
* @returns {Promise<number>}
216210
* @static
217211
*/
218-
async length(): number {
212+
async length(): Promise<number> {
219213
const queueData = await this.getQueue();
220214
return queueData.length;
221215
},
@@ -268,7 +262,7 @@ const EventuallyQueue = {
268262
// Queued update was overwritten by other request. Do not save
269263
if (
270264
typeof object.updatedAt !== 'undefined' &&
271-
object.updatedAt > new Date(queueObject.object.createdAt)
265+
object.updatedAt > new Date(queueObject.object.createdAt as Date)
272266
) {
273267
return this.remove(queueObject.queueId);
274268
}
@@ -345,7 +339,7 @@ const EventuallyQueue = {
345339
},
346340

347341
_setPolling(flag: boolean) {
348-
polling = flag;
342+
polling = flag as any;
349343
},
350344

351345
process: {

src/IndexedDBStorageController.js src/IndexedDBStorageController.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
/**
2-
* @flow
3-
*/
41
/* global window */
52

63
import { createStore, del, set, get, clear, keys } from 'idb-keyval';
74

5+
let IndexedDBStorageController: any;
6+
87
if (typeof window !== 'undefined' && window.indexedDB) {
98
try {
109
const ParseStore = createStore('parseDB', 'parseStore');
1110

12-
const IndexedDBStorageController = {
11+
IndexedDBStorageController = {
1312
async: 1,
1413
getItemAsync(path: string) {
1514
return get(path, ParseStore);
@@ -27,13 +26,13 @@ if (typeof window !== 'undefined' && window.indexedDB) {
2726
return clear(ParseStore);
2827
},
2928
};
30-
31-
module.exports = IndexedDBStorageController;
3229
} catch (_) {
3330
// IndexedDB not accessible
34-
module.exports = undefined;
31+
IndexedDBStorageController = undefined;
3532
}
3633
} else {
3734
// IndexedDB not supported
38-
module.exports = undefined;
35+
IndexedDBStorageController = undefined;
3936
}
37+
module.exports = IndexedDBStorageController;
38+
export default IndexedDBStorageController;

0 commit comments

Comments
 (0)