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 #916

Open
AlvaroParker opened this issue Jul 21, 2024 · 0 comments
Open

No overload matches this call #916

AlvaroParker opened this issue Jul 21, 2024 · 0 comments

Comments

@AlvaroParker
Copy link

AlvaroParker commented Jul 21, 2024

The following snippet is generating an error:

import client from "./driver";

export interface Course {
    id?: number;
    name: string;
    description: string;
    price: number;
    image: string;
}

export interface UpdateCourse {
    name?: string;
    description?: string;
    price?: number;
    image?: string;
}

export const updateCourse = async (id: number, course: UpdateCourse) => {
    // Get list of non-null keys
    const keys = Object.keys(course).filter(
        (key) => course[key as keyof UpdateCourse] // If this is not null
    );
    const res = await client<Course[]>`UPDATE courses SET  ${client(course, keys)} WHERE id = ${id} RETURNING *`;
};

Error:

No overload matches this call.
  Argument of type '[string[]]' is not assignable to parameter of type 'readonly ("name" | "description" | "price" | "image")[] | [readonly ("name" | "description" | "price" | "image")[]]'.
    Type '[string[]]' is not assignable to type '[readonly ("name" | "description" | "price" | "image")[]]'.
      Type 'string[]' is not assignable to type 'readonly ("name" | "description" | "price" | "image")[]'.
        Type 'string' is not assignable to type '"name" | "description" | "price" | "image"'.
  Overload 2 of 2, '(template: TemplateStringsArray, ...parameters: readonly ParameterOrFragment<never>[]): PendingQuery<any>', gave the following error.
    Argument of type 'UpdateCourse' is not assignable to parameter of type 'TemplateStringsArray'.
      Type 'UpdateCourse' is missing the following properties from type 'TemplateStringsArray': raw, length, concat, join, and 27 more.

The function does work, but ts it's returning an error either way.

I'm using version 3.4.4

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

No branches or pull requests

1 participant