sqliteTable wrapper which modifies fields, with proper types

More of a TypeScript question, but I'm trying to create a wrapper for sqliteTable to add a set of standard fields (and keys) to the fields provided:

import { sqliteTable, SQLiteTableFn } from "drizzle-orm/sqlite-core"

const extraFields = { ... }

const wrapper: SQLiteTableFn = (name, fields, keys) => {
  return sqliteTable(
    name,
    { ...extraFields, ...fields },
    (Table) => ({ ...keys })
  );
};


This results in a type error on wrapper as the generics applied to SQLiteTableFn and the return value of wrapper return value
sqliteTable
on modified fields) no longer correspond. How can I create a type for wrapper which returns object properly typed?
Was this page helpful?