Skip to content

Tanstack Start: useSpacetimeDBQuery returns untyped rows #4441

@vaneworks

Description

@vaneworks

Problem
useSpacetimeDBQuery returns RowType[] instead of inferring the row type from the table passed to it. There's no type safety on the returned data.

tsconst [people] = useSpacetimeDBQuery(tables.person);
// type is RowType<UntypedTableDef>[] — no autocomplete, no type checking

tables.person already carries the full type information for its rows. useSpacetimeDBQuery should be able to infer the row type from the table argument so that people is typed as { name: string }[] (or whatever the table schema defines) without needing a manual generic.

Expected behavior

tsconst [people] = useSpacetimeDBQuery(tables.person);
// type should be { name: string }[] — inferred from tables.person
people[0].name  // ✅ autocomplete works
people[0].foo   // ❌ type error

Reproduce
Install via spacetime dev --template tanstack-ts and observe response of const [people] = useSpacetimeDBQuery(tables.person);

ts settings

...
  "devDependencies": {
    "oxfmt": "^0.35.0",
    "oxlint": "^1.50.0",
    "oxlint-tsgolint": "^0.15.0",
    "turbo": "^2.8.10",
    "typescript": "5.9.3"
  },
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions