Open
Description
If I have:
type InnerTest = {
aProp: number
}
type OuterTest = {
inner: InnerTest
}
const o: OuterTest = {
inner: {
aProp: 5
}
};
await sql `INSERT INTO some_table ${this.db(o)}`
Everything works fine.
If I change OuterTest to a class instead of a type, it still works.
But, If I change InnerTest to a class instead of a type, I get:
No overload matches this call.
Overload 1 of 2, '(first: OuterTest & Partial<Record<"inner", ParameterOrJSON<never>> & Record<string, any>>): Helper<OuterTest, []>', gave the following error.
Argument of type 'OuterTest' is not assignable to parameter of type 'OuterTest & Partial<Record<"inner", ParameterOrJSON<never>> & Record<string, any>>'.
Type 'OuterTest' is not assignable to type 'Partial<Record<"inner", ParameterOrJSON<never>> & Record<string, any>>'.
Types of property 'inner' are incompatible.
Type 'InnerTest' is not assignable to type 'ParameterOrJSON<never>'.
Type 'InnerTest' is not assignable to type '{ readonly [prop: string]: JSONValue | ((...args: any) => any); readonly [prop: number]: JSONValue | ((...args: any) => any); }'.
Index signature for type 'string' is missing in type 'InnerTest'.
Overload 2 of 2, '(template: TemplateStringsArray, ...parameters: readonly ParameterOrFragment<never>[]): PendingQuery<Row[]>', gave the following error.
Argument of type 'OuterTest' is not assignable to parameter of type 'TemplateStringsArray'.
Type 'OuterTest' is missing the following properties from type 'TemplateStringsArray': raw, length, concat, join, and 21 more.ts(2769)
const o: OuterTest
No quick fixes available
The only workaround seems to be to coerce sql to type any instead of postgres.Sql<{}>, but I'm not sure the consequences of that. It seems to basically turn off any type checking altogether.
Metadata
Metadata
Assignees
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity