Typing with inserts
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 8.7k
- Forks
- 374
- Avg merge
- 11d 16h
- Merged PRs (30d)
- 1
Description
Hi there. What a lovely library. I'm encountering a typing issue with dynamic inserts: Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.
const users = [{
name: 'Murray',
age: 68,
garbage: 'ignore'
},
{
name: 'Walter',
age: 80
}];
await sql`insert into users ${sql(users, 'name', 'age')}`; // fine
await sql`insert into users ${sql(users, 'name', 'age')} returning id`; // fine
await sql<{ id: number }[]>`insert into users ${sql(users, 'name', 'age')} returning id`; // Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.
something I'm doing wrong?
Contributor guide
No contributing guide indexed for this repository
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 with the TypeScript reproduction in the issue and compare the inferred type of the tagged query with and without the explicit result type. The issue is done when the explicit generic compiles without the await error while the existing insert examples continue to type-check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgres, typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100