Skip to content

Commit e86718f

Browse files
authored
feat: Add TypeScript definitions (#9693)
1 parent 39ef22d commit e86718f

19 files changed

+1482
-36
lines changed

Diff for: .github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ jobs:
147147
- run: npm ci
148148
- name: Build types
149149
run: npm run build:types
150+
- name: Test Types
151+
run: npm run test:types
150152
check-mongo:
151153
strategy:
152154
matrix:

Diff for: .npmignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
types/tests.ts
2+
types/eslint.config.mjs

Diff for: CONTRIBUTING.md

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- [Good to Know](#good-to-know)
2222
- [Troubleshooting](#troubleshooting)
2323
- [Please Do's](#please-dos)
24+
- [TypeScript Tests](#typescript-tests)
2425
- [Test against Postgres](#test-against-postgres)
2526
- [Postgres with Docker](#postgres-with-docker)
2627
- [Breaking Changes](#breaking-changes)
@@ -239,6 +240,15 @@ Once you have babel running in watch mode, you can start making changes to parse
239240
* Mocks belong in the `spec/support` folder.
240241
* Please consider if any changes to the [docs](http://docs.parseplatform.org) are needed or add additional sections in the case of an enhancement or feature.
241242

243+
#### TypeScript Tests
244+
245+
Type tests are located in [/types/tests.ts](/types/tests.ts) and are responsible for ensuring that the type generation for each class is behaving as expected. Types are generated by manually running the script `npm run build:types`. The generated types are `.d.ts` files located in [/types](/types) and must not be manually changed after generation.
246+
247+
> [!CAUTION]
248+
> An exemption are type changes to `src/Options/index.js` which must be manually updated in `types/Options/index.d.ts`, as these types are not generated via a script.
249+
250+
When developing type definitions you can run `npm run watch:ts` in order to rebuild your changes automatically upon each save. Use `npm run test:types` in order to run types tests against generated `.d.ts` files.
251+
242252
### Test against Postgres
243253

244254
If your pull request introduces a change that may affect the storage or retrieval of objects, you may want to make sure it plays nice with Postgres.

Diff for: eslint.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const babelParser = require("@babel/eslint-parser");
33
const globals = require("globals");
44
module.exports = [
55
{
6-
ignores: ["**/lib/**", "**/coverage/**", "**/out/**"],
6+
ignores: ["**/lib/**", "**/coverage/**", "**/out/**", "**/types/**"],
77
},
88
js.configs.recommended,
99
{

0 commit comments

Comments
 (0)