[x: string]: never

I can not find the issue in my code, I would be glad if someone could take a quick look Drizzle return type:
let res: {
id: number;
productId: number;
salesTaxRateId: number;
product: {
id: number;
};
salesTaxRate: {
[x: string]: never;
};
}[]
let res: {
id: number;
productId: number;
salesTaxRateId: number;
product: {
id: number;
};
salesTaxRate: {
[x: string]: never;
};
}[]
with such query:
let res = await db.query.skuTable.findMany({
with: {
salesTaxRate: true,
product: true
}
})
let res = await db.query.skuTable.findMany({
with: {
salesTaxRate: true,
product: true
}
})
which is incorrect... why salesTaxRate is not typed properly? relations seems to be fine
import { relations } from "drizzle-orm";
import { decimal, integer, pgTable, text } from "drizzle-orm/pg-core";
import { taxRateTable } from "./tax-rate.schema";
import { productTable } from "./product.schema";

export const skuTable = pgTable('sku', {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
productId: integer('product_id').notNull(),
salesTaxRateId: integer('sales_tax_rate_id').notNull(),
})

export const skuRelations = relations(skuTable, ({ one }) => ({
salesTaxRate: one(taxRateTable, {
fields: [skuTable.salesTaxRateId],
references: [taxRateTable.id],
}),
product: one(productTable, {
fields: [skuTable.productId],
references: [productTable.id],
}),
}));

export const productTable = pgTable('product', {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
})

export const taxRateTable = pgTable('tax_rate', {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
})
import { relations } from "drizzle-orm";
import { decimal, integer, pgTable, text } from "drizzle-orm/pg-core";
import { taxRateTable } from "./tax-rate.schema";
import { productTable } from "./product.schema";

export const skuTable = pgTable('sku', {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
productId: integer('product_id').notNull(),
salesTaxRateId: integer('sales_tax_rate_id').notNull(),
})

export const skuRelations = relations(skuTable, ({ one }) => ({
salesTaxRate: one(taxRateTable, {
fields: [skuTable.salesTaxRateId],
references: [taxRateTable.id],
}),
product: one(productTable, {
fields: [skuTable.productId],
references: [productTable.id],
}),
}));

export const productTable = pgTable('product', {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
})

export const taxRateTable = pgTable('tax_rate', {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
})
1 Reply
tzezar
tzezarOP2mo ago
and my drizzle.ts config with schemas imported like shown in docs:
import 'dotenv/config';
import { drizzle } from 'drizzle-orm/node-postgres';
import * as schema from './schema/product.schema';
import * as schema2 from './schema/sku.schema';

const db = drizzle(process.env.DATABASE_URL!, {
schema: {
...schema,
...schema2,
},
});

export default db
import 'dotenv/config';
import { drizzle } from 'drizzle-orm/node-postgres';
import * as schema from './schema/product.schema';
import * as schema2 from './schema/sku.schema';

const db = drizzle(process.env.DATABASE_URL!, {
schema: {
...schema,
...schema2,
},
});

export default db

Did you find this page helpful?