Skip to content

Typing with inserts #958

Open
Open
@noslouch

Description

@noslouch

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions