I've set up my bookshelf instance in a configuration file as follows:
// Omitted irrelevant code
const knex = Knex(knexfile[env]);
const bookshelf = Bookshelf(knex as any);
const { Model } = bookshelf;
export default Model;
export { bookshelf };
Everything is working perfectly fine; the imports and exports are functioning correctly. I have created a model like this:
import Model from '../config/bookshelf';
class Module extends Model<{id:number}> {
table = 'modules';
get tableName() { return this.table; }
}
However, TypeScript throws an error saying
Type '{ id: string; }' is missing the following properties from type 'Model<any>': belongsTo, belongsToMany, count, destroy, and 41 more.
It seems like TypeScript expects the type provided for Model to define all methods on the Model class that it extends from, which contradicts information found in this stackoverflow post and the DefinitelyTyped example. Any suggestions on how to resolve this without adding all 40-something methods to my model's type?
Appreciate any insights!