Reputation: 11305
How best to type the below code without the Promise: any
as I currently have it?
export const up = function(knex: knex, Promise: any): Promise<knex> {
return Promise.all([
knex.schema.createTable(
'counters',
(table: knex.TableBuilder): void => {
table.increments('id').primary();
table.integer('count');
}
),
]);
};
I have tried PromiseConstructor
but then there is an error with Promise<knex>
being returned. Can't seem to find any documentation on typing knex.js
migrations.
Upvotes: 0
Views: 549
Reputation: 1551
Why should the return type be Promise<knex>
?
knex.schema.createTable
returns a SchemaBuilder
which extends ChainableInterface
, which ultimately extends Bluebird<any>
, so the return type is Promise<any[]>
.
Upvotes: 2