Fix TypeScript table handle casing#5286
Open
clockwork-labs-bot wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_treebecomesctx.db.databaseTreetables.logged_out_playerbecomestables.loggedOutPlayertables.my_progressbecomestables.myProgressThe 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_nameandview.accessor_namedirectly as object keys intablesSchema. That preserved the raw module accessor spelling instead of applying the target-languageCase::Camelconversion. This made TS table handles drift from the intended client casing policy.What changed
Case::Camel.Generated code in this repo that changes as a result:
crates/bindings-typescript/test-app/src/module_bindings/index.tscrates/bindings-typescript/test-react-router-app/src/module_bindings/index.tscrates/bindings-typescript/test-solid-router/src/module_bindings/index.tscrates/bindings-typescript/case-conversion-test-client/src/module_bindings/index.tsdemo/Blackholio/client-ts/src/module_bindings/index.tstemplates/hangman-react-ts/src/module_bindings/index.tstemplates/money-exchange-react-ts/src/module_bindings/index.tscrates/codegen/tests/snapshots/codegen__codegen_typescript.snapI also updated the corresponding client/test references to the new generated handle names.
Verification
cargo test -p spacetimedb-codegen typescriptcargo fmt --all --checkgit diff --checkprettier --checkon touched TS files that already match repo Prettier styleFull
pnpm --dir crates/bindings-typescript lintcould not run in the temporary worktree because it has nonode_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.