Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No overload matches this call #685

Closed
dinogomez opened this issue Sep 29, 2023 · 3 comments
Closed

No overload matches this call #685

dinogomez opened this issue Sep 29, 2023 · 3 comments

Comments

@dinogomez
Copy link

dinogomez commented Sep 29, 2023

const user = {
    firstName: firstName,
    lastName: lastName,
    userName: userName,
    password: hashedPassword,
};
const columns = ["firstName", "lastName", "userName", "password"];

const res = await sql`insert into users ${sql(user, columns)}`; //error on "${sql(user, columns)}"

This code gives a No overload matches this call

No overload matches this call.
  Argument of type '[Helper<{ firstName: any; lastName: any; userName: any; password: any; }, readonly ("firstName" | "lastName" | "userName" | "password")[]>]' is not assignable to parameter of type 'never'.
  Overload 2 of 2, '(template: TemplateStringsArray, ...parameters: readonly ParameterOrFragment<never>[]): PendingQuery<Row[]>', gave the following error.
    Argument of type 'Helper<{ firstName: any; lastName: any; userName: any; password: any; }, readonly ("firstName" | "lastName" | "userName" | "password")[]>' is not assignable to parameter of type 'ParameterOrFragment<never>'.
      Type 'Helper<{ firstName: any; lastName: any; userName: any; password: any; }, readonly ("firstName" | "lastName" | "userName" | "password")[]>' is not assignable to type 'Helper<any, any[]>'.
        The type 'readonly ("firstName" | "lastName" | "userName" | "password")[]' is 'readonly' and cannot be assigned to the mutable type 'any[]'.ts(2769)
No overload matches this call.
  Overload 1 of 2, '(first: { firstName: any; lastName: any; userName: any; password: any; }, ...rest: readonly ("firstName" | "lastName" | "userName" | "password")[]): Helper<{ firstName: any; lastName: any; userName: any; password: any; }, readonly ("firstName" | ... 2 more ... | "password")[]>', gave the following error.
    Argument of type 'string[]' is not assignable to parameter of type '"firstName" | "lastName" | "userName" | "password"'.
  Overload 2 of 2, '(template: TemplateStringsArray, ...parameters: readonly ParameterOrFragment<never>[]): PendingQuery<Row[]>', gave the following error.
    Argument of type '{ firstName: any; lastName: any; userName: any; password: any; }' is not assignable to parameter of type 'TemplateStringsArray'.
      Type '{ firstName: any; lastName: any; userName: any; password: any; }' is missing the following properties from type 'TemplateStringsArray': raw, length, concat, join, and 27 more.ts(2769)
const user: {
    firstName: any;
    lastName: any;
    userName: any;
    password: any;
}

The code above still works though and will still insert into the database.
image

Kinda confused on how to proceed, following the guide here in dynamic inserts on the docs.

@alpharder
Copy link
Contributor

Will be fixed by #679

@alpharder
Copy link
Contributor

@dinogomez Please confirm the latest release resolves your problem and consider closing the issue if so.

@dinogomez
Copy link
Author

@alpharder On updating to 3.4.0, can confirm typescript errors on overload are handled. Thank you for the hard work 💙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants