-
Notifications
You must be signed in to change notification settings - Fork 316
Closed
Labels
Description
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.
Is this the intended behavior?
tsconfig
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022",
"strict": true,
"sourceMap": true,
"outDir": "dist",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
}