I am getting what appears to be inconsistent TypeScript errors when writing dynamic insert queries:
Issue
// No errors:
const users = await sql<UserDto[]>`INSERT INTO users ${sql(payload)} returning *`;
// or
const helper = sql(payload, "username", "email", "password");
const users = await sql<UserDto[]>`INSERT INTO users ${helper} returning *`;
// Error: Type of operand must either be a valid promise or must not contain a callable then member.
const users = await sql<UserDto[]>`INSERT INTO users ${sql(payload, "username", "email", "password")} returning *`;
Expected
I would expect all three above to be valid but the last one throws a TypeScript error.
I am getting what appears to be inconsistent TypeScript errors when writing dynamic insert queries:
Issue
Expected I would expect all three above to be valid but the last one throws a TypeScript error.
Is this the intended behavior?
tsconfig