tursodatabase / tursodatabase/libsql-client-ts
Generic `ResultSet` for better typing
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 576
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
The db.execute method currently returns a non-generic ResultSet type. However, in some cases, the column and row types are known beforehand. By making ResultSet generic, developers could provide these types, enhancing the developer experience (DX).
For instance, a table with columns imageId, filename, and data only provides a length property when using the standard db.execute return type. To return the data column in a Response object (new Response(result.data)), a workaround like this is needed:
type ExtendedResultSet<T> = ResultSet & {
rows: T[];
};
This allows functions to return an ExtendedResultSet<ImageRow>, where the rows property is typed based on the specific row type.
This approach saves time and reduces debugging when table modifications occur. I'm Happy to contribute to this improvement if the team approves.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the TypeScript declarations behind db.execute and ResultSet. Use the ImageRow example to define the intended generic typing, then verify that result.data can be passed to Response while existing non-generic usage remains valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100