Skip to content

Commit 1630f0c

Browse files
Fixes reported issues with the TypeScript SDK (#3737)
# Description of Changes Fixes: - [This issue](https://discord.com/channels/1037340874172014652/1398209084699709492/1441556875647647816) by exporting the `SubscriptionHandle` type with the `REMOTE_MODULE` type applied. - [This issue](https://discord.com/channels/1037340874172014652/1398209084699709492/1441559246213746749) by converting to `camelCase` for column names in code generation. - Fixes an issue where `onMyReducer` callbacks were passing arguments as variadic params, while the types indicated they would be passed as an object. `onMyReducer((ctx, argA, argB, argC) => {})` vs onMyReducer((ctx, { argA, argB, argC}) => {})` - [Fixes an issue](#3503 (comment)) where the table type name was used instead of the table name in code generation for constructing tables. - [Fixes issue](https://discord.com/channels/1037340874172014652/1398209084699709492/1441886030436499466) with `ScheduleAt` being used in non-table types. - [Fixes issue](clockworklabs/SpacetimeDBPrivate#2168) where template projects do not use the correct lifecycle reducer setup # API and ABI breaking changes Adds a new export, and fixes casing in code genreation. # Expected complexity level and risk 2 # Testing - I have tested that the `SubscriptionHandle` is correctly exported - I have tested that the constraint name is now output in `camelCase` - I have tested that `onMyReducer` callbacks now return a single argument - I have tested that the table name (and view name) is now used instead of the type name for code generation - I have tested that the new lifecycle reducers correctly compile
1 parent 7ca16de commit 1630f0c

29 files changed

Lines changed: 503 additions & 102 deletions

File tree

crates/bindings-typescript/examples/basic-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "vite",
88
"build": "tsc -b && vite build",
99
"preview": "vite preview",
10-
"generate": "cargo run -p gen-bindings -- --out-dir src/module_bindings --project-path ../../../cli/templates/basic-typescript/server && prettier --write src/module_bindings",
10+
"generate": "pnpm --dir ../../../cli/templates/basic-typescript/server install --ignore-workspace && cargo run -p gen-bindings -- --out-dir src/module_bindings --project-path ../../../cli/templates/basic-typescript/server && prettier --write src/module_bindings",
1111
"spacetime:generate": "spacetime generate --lang typescript --out-dir src/module_bindings --project-path spacetimedb",
1212
"spacetime:publish:local": "spacetime publish --project-path server --server local",
1313
"spacetime:publish": "spacetime publish --project-path server --server maincloud"

crates/bindings-typescript/examples/basic-react/src/module_bindings/index.ts

Lines changed: 29 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/examples/basic-react/src/module_bindings/on_connect_reducer.ts

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/examples/basic-react/src/module_bindings/on_connect_type.ts

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/examples/basic-react/src/module_bindings/on_disconnect_reducer.ts

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/examples/basic-react/src/module_bindings/on_disconnect_type.ts

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/examples/empty/src/module_bindings/index.ts

Lines changed: 29 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/examples/empty/src/module_bindings/on_connect_reducer.ts

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/examples/empty/src/module_bindings/on_connect_type.ts

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/examples/empty/src/module_bindings/on_disconnect_reducer.ts

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)