Skip to content

Fix TypeScript table handle casing#5286

Open
clockwork-labs-bot wants to merge 1 commit into
masterfrom
bot/fix-ts-table-handle-casing
Open

Fix TypeScript table handle casing#5286
clockwork-labs-bot wants to merge 1 commit into
masterfrom
bot/fix-ts-table-handle-casing

Conversation

@clockwork-labs-bot

Copy link
Copy Markdown
Contributor

⚠️ BREAKING CHANGE

This changes generated TypeScript client table/view handles for snake_case module accessors.

Generated TS clients will now expose table and view handles using TypeScript casing, matching the casing policy design:

  • ctx.db.database_tree becomes ctx.db.databaseTree
  • tables.logged_out_player becomes tables.loggedOutPlayer
  • tables.my_progress becomes tables.myProgress

The underlying wire/table names stay unchanged. For example, the generated handle is camelCase, but the table metadata still has name: 'logged_out_player'.

Why

The TypeScript code generator was using table.accessor_name and view.accessor_name directly as object keys in tablesSchema. That preserved the raw module accessor spelling instead of applying the target-language Case::Camel conversion. This made TS table handles drift from the intended client casing policy.

What changed

  • Convert generated TypeScript table and view handle keys with Case::Camel.
  • Add a regression test that asserts snake_case table/view accessors generate camelCase TS handles.
  • Update the TypeScript codegen snapshot.
  • Update checked-in generated TS bindings and references that change under this fix.

Generated code in this repo that changes as a result:

  • crates/bindings-typescript/test-app/src/module_bindings/index.ts
  • crates/bindings-typescript/test-react-router-app/src/module_bindings/index.ts
  • crates/bindings-typescript/test-solid-router/src/module_bindings/index.ts
  • crates/bindings-typescript/case-conversion-test-client/src/module_bindings/index.ts
  • demo/Blackholio/client-ts/src/module_bindings/index.ts
  • templates/hangman-react-ts/src/module_bindings/index.ts
  • templates/money-exchange-react-ts/src/module_bindings/index.ts
  • crates/codegen/tests/snapshots/codegen__codegen_typescript.snap

I also updated the corresponding client/test references to the new generated handle names.

Verification

  • cargo test -p spacetimedb-codegen typescript
  • cargo fmt --all --check
  • git diff --check
  • prettier --check on touched TS files that already match repo Prettier style

Full pnpm --dir crates/bindings-typescript lint could not run in the temporary worktree because it has no node_modules; a symlink workaround still failed eslint module resolution before linting project files. The changed non-Blackholio TS files pass Prettier check. Blackholio generated/client files were left in their existing local formatting style to avoid unrelated formatting churn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant