No overload matches this call
I'm sorry that I'm already the 4th person with this sort of post, but the other posts didn't really help me out. I'm having an issue where it's sayig a certain attribute isn't in the type generated, but I don't see why not, and when I run the code it does work
Here's the schema:
Here's the error:
No overload matches this call.
Overload 2 of 2, '(values: { name: string | SQL<unknown> | Placeholder<string, any>; nif: string | SQL<unknown> | Placeholder<string, any>; password: SQL<unknown> | Buffer | Placeholder<...>; ... 5 more ...; services?: number | ... 2 more ... | undefined; }[]): PgInsertBase<...>', gave the following error.
Object literal may only specify known properties, and 'name' does not exist in type '{ name: string | SQL<unknown> | Placeholder<string, any>; nif: string | SQL<unknown> | Placeholder<string, any>; password: SQL<unknown> | Buffer | Placeholder<...>; ... 5 more ...; services?: number | ... 2 more ... | undefined; }[]'.
9 Replies
@Tomathy Are you using a monorepo?
no, just a single project
I see a
bytea
type that isn't part of Drizzle. I assume that's a custom type, what's the definition for that type?
From the error message, it seems it's not recognizing name as an attribute :/
Just to confirm that the bytea type isn't causing issues, can you change the data attribute to string and see if there's still type errors?
Tried it, but gives the same error but for a different attribute? It's so weird seeing as the first error was for "name" and not the bytea attribute. Nw it's just pointing out the enum 🤔
Here's the new schema:
Here's the new error:
No overload matches this call.
Overload 1 of 2, '(value: { name: string | SQL<unknown> | Placeholder<string, any>; nif: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; ... 5 more ...; services?: number | ... 2 more ... | undefined; }): PgInsertBase<...>', gave the following error.
Type 'string' is not assignable to type 'SQL<unknown> | "ATIVO" | "NÃO ATIVO" | "SUSPENSO" | Placeholder<string, any>'.
Overload 2 of 2, '(values: { name: string | SQL<unknown> | Placeholder<string, any>; nif: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; ... 5 more ...; services?: number | ... 2 more ... | undefined; }[]): PgInsertBase<...>', gave the following error.
Object literal may only specify known properties, and 'name' does not exist in type '{ name: string | SQL<unknown> | Placeholder<string, any>; nif: string | SQL<unknown> | Placeholder<string, any>; ... (Discord limit)
I think it might have to do with one of the two enum fields
In the insert statement I see this:
My guess is that
client_activity[faker.number.int({min: 0, max: 2})]
returns type string
instead of the exact type the enum is looking forbut the enum is composed of strings. Is there a way to export/import the enums type and how do I insert enum values into the table?
You can do something like this:
You might get a type error with
faker.number.int({min: 0, max: 2})
, in that case you can just cast: