feat: Add TypeScript support (#9550)
This commit is contained in:
6
.babelrc
6
.babelrc
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"plugins": [
|
||||
"@babel/plugin-transform-flow-strip-types",
|
||||
"@babel/plugin-proposal-object-rest-spread"
|
||||
"@babel/plugin-transform-flow-strip-types"
|
||||
],
|
||||
"presets": [
|
||||
"@babel/preset-typescript",
|
||||
["@babel/preset-env", {
|
||||
"targets": {
|
||||
"node": "14",
|
||||
"node": "18"
|
||||
},
|
||||
"exclude": ["proposal-dynamic-import"]
|
||||
}]
|
||||
|
||||
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
@@ -138,6 +138,17 @@ jobs:
|
||||
uses: mansona/npm-lockfile-version@v1
|
||||
with:
|
||||
version: 2
|
||||
check-types:
|
||||
name: Check Types
|
||||
timeout-minutes: 5
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: npm ci
|
||||
- name: Build types
|
||||
run: npm run build:types
|
||||
- name: Check types
|
||||
run: npm run test:types
|
||||
check-mongo:
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -46,6 +46,8 @@ node_modules
|
||||
|
||||
# Babel.js
|
||||
lib/
|
||||
# types/* once we have full typescript support, we can generate types from the typescript files
|
||||
!types/tsconfig.json
|
||||
|
||||
# cache folder
|
||||
.cache
|
||||
|
||||
3007
package-lock.json
generated
3007
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@@ -15,7 +15,8 @@
|
||||
"LICENSE",
|
||||
"NOTICE",
|
||||
"postinstall.js",
|
||||
"README.md"
|
||||
"README.md",
|
||||
"types"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -73,6 +74,8 @@
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.20.7",
|
||||
"@babel/plugin-transform-flow-strip-types": "7.26.5",
|
||||
"@babel/preset-env": "7.26.0",
|
||||
"@babel/preset-typescript": "7.26.0",
|
||||
"@definitelytyped/dtslint": "0.0.163",
|
||||
"@saithodev/semantic-release-backmerge": "4.0.1",
|
||||
"@semantic-release/changelog": "6.0.3",
|
||||
"@semantic-release/commit-analyzer": "13.0.1",
|
||||
@@ -106,6 +109,7 @@
|
||||
"nyc": "17.1.0",
|
||||
"prettier": "2.0.5",
|
||||
"semantic-release": "24.2.1",
|
||||
"typescript": "5.7.3",
|
||||
"yaml": "2.7.0"
|
||||
},
|
||||
"scripts": {
|
||||
@@ -114,9 +118,10 @@
|
||||
"ci:definitionsCheck": "node ./ci/definitionsCheck.js",
|
||||
"definitions": "node ./resources/buildConfigDefinitions.js && prettier --write 'src/Options/*.js'",
|
||||
"docs": "jsdoc -c ./jsdoc-conf.json",
|
||||
"lint": "flow && eslint --cache ./",
|
||||
"lint": "eslint --cache ./",
|
||||
"lint-fix": "eslint --fix --cache ./",
|
||||
"build": "babel src/ -d lib/ --copy-files",
|
||||
"build": "babel src/ -d lib/ --copy-files --extensions '.ts,.js'",
|
||||
"build:types": "tsc",
|
||||
"watch": "babel --watch src/ -d lib/ --copy-files",
|
||||
"test:mongodb:runnerstart": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=$npm_config_dbversion} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} mongodb-runner start -t ${MONGODB_TOPOLOGY} --version ${MONGODB_VERSION} -- --port 27017",
|
||||
"test:mongodb:testonly": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=$npm_config_dbversion} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 jasmine",
|
||||
@@ -125,6 +130,7 @@
|
||||
"test:mongodb:7.0.16": "npm run test:mongodb --dbversion=7.0.16",
|
||||
"test:mongodb:8.0.4": "npm run test:mongodb --dbversion=8.0.4",
|
||||
"test:postgres:testonly": "cross-env PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_TEST_DATABASE_URI=postgres://postgres:password@localhost:5432/parse_server_postgres_adapter_test_database npm run testonly",
|
||||
"test:types": "dtslint --expectOnly types",
|
||||
"pretest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=8.0.4} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} mongodb-runner start -t ${MONGODB_TOPOLOGY} --version ${MONGODB_VERSION} -- --port 27017",
|
||||
"testonly": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=8.0.4} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 jasmine",
|
||||
"test": "npm run testonly",
|
||||
@@ -136,6 +142,7 @@
|
||||
"postinstall": "node -p 'require(\"./postinstall.js\")()'",
|
||||
"madge:circular": "node_modules/.bin/madge ./src --circular"
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"engines": {
|
||||
"node": ">=18.20.4 <19.0.0 || >=20.18.0 <21.0.0 || >=22.12.0 <23.0.0"
|
||||
},
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
"@babel/plugin-proposal-object-rest-spread"
|
||||
],
|
||||
"presets": [
|
||||
"@babel/preset-typescript",
|
||||
["@babel/preset-env", {
|
||||
"targets": {
|
||||
"node": "14"
|
||||
"node": "18"
|
||||
}
|
||||
}]
|
||||
],
|
||||
"sourceMaps": "inline",
|
||||
"retainLines": true
|
||||
"sourceMaps": "inline"
|
||||
}
|
||||
|
||||
13
tsconfig.json
Normal file
13
tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "types",
|
||||
"noImplicitAny": false,
|
||||
"allowJs": false,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": [
|
||||
"src/*.ts"
|
||||
]
|
||||
}
|
||||
0
types/index.d.ts
vendored
Normal file
0
types/index.d.ts
vendored
Normal file
2
types/logger.d.ts
vendored
Normal file
2
types/logger.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare function setLogger(aLogger: any): void;
|
||||
export declare function getLogger(): any;
|
||||
18
types/tsconfig.json
Normal file
18
types/tsconfig.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
|
||||
// If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index".
|
||||
// If the library is global (cannot be imported via `import` or `require`), leave this out.
|
||||
"baseUrl": ".",
|
||||
"paths": { "parse": ["."] }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user