Skip to content

Commit 54efcf5

Browse files
authored
refactor: Add TypeScript support (#1985)
1 parent 549b7b3 commit 54efcf5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+10103
-542
lines changed

Diff for: .github/workflows/ci.yml

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ jobs:
1616
uses: mansona/npm-lockfile-version@v1
1717
with:
1818
version: 2
19+
check-types:
20+
name: Check types
21+
timeout-minutes: 5
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v3
25+
- run: npm ci
26+
- name: Check types
27+
run: npm run test:types
1928
build:
2029
runs-on: ubuntu-latest
2130
timeout-minutes: 30

Diff for: babel-jest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const babelJest = require('babel-jest');
22

33
module.exports = babelJest.createTransformer({
4-
presets: [["@babel/preset-env", {
4+
presets: ["@babel/preset-typescript", ["@babel/preset-env", {
55
"targets": {
66
"node": "14"
77
},

Diff for: gulpfile.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ const transformRuntime = ["@babel/plugin-transform-runtime", {
2020
}];
2121

2222
const PRESETS = {
23-
'browser': [["@babel/preset-env", {
23+
'browser': ["@babel/preset-typescript", ["@babel/preset-env", {
2424
"targets": "> 0.25%, not dead"
2525
}]],
26-
'weapp': [["@babel/preset-env", {
26+
'weapp': ["@babel/preset-typescript", ["@babel/preset-env", {
2727
"targets": "> 0.25%, not dead"
2828
}], '@babel/react'],
29-
'node': [["@babel/preset-env", {
29+
'node': ["@babel/preset-typescript", ["@babel/preset-env", {
3030
"targets": { "node": "14" }
3131
}]],
32-
'react-native': ['module:metro-react-native-babel-preset'],
32+
'react-native': ["@babel/preset-typescript", 'module:metro-react-native-babel-preset'],
3333
};
3434
const PLUGINS = {
3535
'browser': [transformRuntime, '@babel/plugin-transform-flow-comments', '@babel/plugin-proposal-class-properties', 'inline-package-json',
@@ -79,7 +79,7 @@ function compileTask(stream) {
7979
}
8080

8181
gulp.task('compile', function() {
82-
return compileTask(gulp.src('src/*.js'));
82+
return compileTask(gulp.src('src/*.*(js|ts)'));
8383
});
8484

8585
gulp.task('browserify', function(cb) {
@@ -137,7 +137,7 @@ gulp.task('minify-weapp', function() {
137137

138138
gulp.task('watch', function() {
139139
if (BUILD === 'browser') {
140-
const watcher = gulp.watch('src/*.js', { ignoreInitial: false }, gulp.series('compile', 'browserify', 'minify'));
140+
const watcher = gulp.watch('src/*.*(js|ts)', { ignoreInitial: false }, gulp.series('compile', 'browserify', 'minify'));
141141
watcher.on('add', function(path) {
142142
console.log(`File ${path} was added`);
143143
});
@@ -146,5 +146,5 @@ gulp.task('watch', function() {
146146
});
147147
return watcher;
148148
}
149-
return compileTask(watch('src/*.js', { ignoreInitial: false, verbose: true }));
149+
return compileTask(watch('src/*.*(js|ts)', { ignoreInitial: false, verbose: true }));
150150
});

Diff for: package-lock.json

+2,276-185
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
"@babel/plugin-transform-runtime": "7.21.4",
4646
"@babel/preset-env": "7.21.5",
4747
"@babel/preset-react": "7.22.5",
48+
"@babel/preset-typescript": "7.22.5",
49+
"@definitelytyped/dtslint": "0.0.163",
4850
"@parse/minami": "1.0.0",
4951
"@saithodev/semantic-release-backmerge": "2.1.3",
5052
"@semantic-release/changelog": "6.0.3",
@@ -95,10 +97,12 @@
9597
},
9698
"scripts": {
9799
"build": "node build_releases.js",
100+
"build:types": "tsc",
98101
"release": "node build_releases.js && npm publish",
99102
"test": "cross-env PARSE_BUILD=node jest",
100103
"test:mongodb": "npm run test:mongodb:runnerstart && npm run integration",
101104
"test:mongodb:runnerstart": "mongodb-runner start -- --port 27017",
105+
"test:types": "dtslint --expectOnly types",
102106
"posttest:mongodb": "mongodb-runner stop --all",
103107
"lint": "eslint --cache src/ integration/",
104108
"lint:fix": "eslint --fix --cache src/ integration/",

Diff for: src/CoreManager.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function requireMethods(name: string, methods: Array<string>, controller: any) {
204204
});
205205
}
206206

207-
module.exports = {
207+
const CoreManager = {
208208
get: function (key: string): any {
209209
if (config.hasOwnProperty(key)) {
210210
return config[key];
@@ -468,3 +468,6 @@ module.exports = {
468468
return config['HooksController'];
469469
},
470470
};
471+
472+
module.exports = CoreManager;
473+
export default CoreManager;

Diff for: src/EventuallyQueue.js

+1
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,4 @@ const EventuallyQueue = {
373373
};
374374

375375
module.exports = EventuallyQueue;
376+
export default EventuallyQueue;

Diff for: src/LocalDatastore.js

+1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ const LocalDatastore = {
392392
};
393393

394394
module.exports = LocalDatastore;
395+
export default LocalDatastore;
395396

396397
if (process.env.PARSE_BUILD === 'react-native') {
397398
CoreManager.setLocalDatastoreController(require('./LocalDatastoreController.react-native'));

0 commit comments

Comments
 (0)