mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-03-20 09:01:05 +08:00
NOTE: Cherry-picking https://github.com/clockworklabs/SpacetimeDB/pull/4127 from the `2.0-breaking-changes` branch. ## Original PR Description This changes generated types in ts client bindings. We currently generate a few different types of types: reducer args, procedure args, rows, and user defined types. To avoid potential conflicts between these types (for example, if a user defined a type called `FooRow`, and also had a tabled named `foo`, we would end up with two types named `FooRow`), this puts each set of types in a different file and namespace. We also stopped exporting the `xxxRow` types, because there is always another type generated for those. We now have a `types` directory, which has an `index.ts` with user defined types, along with `reducers.ts` and `procedures.ts` for the types generated for reducer/procedure parameters. ``` import type * as Types from './module_bindings/types'; var currentMessages: Types.Message[] = []; ``` or ``` import { type Message } from './module_bindings/types'; var currentMessages: Message[] = []; ``` This has a couple other changes: - For procedure and reducer types, this adds a suffix of `Args`, since we may want types for the return values in the future. - For all of the types, instead of exposing the schema object, we are now giving the typescript type (e.g. `export type Message = __Infer<typeof MessageRow>;`). I couldn't think of a reason for users to want the schema object, so this should save users from needing to do all of the `Infer` boilerplate. This is a breaking change for v2. 2. This only changes typescript, and it should generally make thing easier to use. --------- Co-authored-by: Jeffrey Dallatezza <jeffreydallatezza@gmail.com>
34 lines
1.1 KiB
JSON
34 lines
1.1 KiB
JSON
{
|
|
"private": true,
|
|
"packageManager": "pnpm@9.7.0",
|
|
"engines": {
|
|
"node": ">=18.0.0",
|
|
"pnpm": ">=9.0.0"
|
|
},
|
|
"type": "module",
|
|
"scripts": {
|
|
"run-all": "pnpm -r -F ./crates/bindings-typescript -F ./crates/bindings-typescript/examples/quickstart-chat -F ./crates/bindings-typescript/test-app -F ./docs -F \"./templates/**\" run",
|
|
"format": "pnpm run-all format && prettier eslint.config.js --write",
|
|
"lint": "pnpm run-all lint && prettier eslint.config.js --check",
|
|
"build": "pnpm run-all build",
|
|
"test": "pnpm run-all test",
|
|
"generate": "pnpm run-all generate",
|
|
"clean": "pnpm -r exec rimraf dist .tsbuildinfo coverage"
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/js": "^9.17.0",
|
|
"@types/node": "^22.10.2",
|
|
"@typescript-eslint/eslint-plugin": "^8.18.2",
|
|
"@typescript-eslint/parser": "^8.18.2",
|
|
"eslint": "^9.17.0",
|
|
"eslint-plugin-jsdoc": "^61.5.0",
|
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
"eslint-plugin-react-refresh": "^0.4.16",
|
|
"globals": "^15.14.0",
|
|
"prettier": "^3.3.3",
|
|
"rimraf": "^6.0.1",
|
|
"typescript": "~5.6.2",
|
|
"vitest": "^3.2.4"
|
|
}
|
|
}
|