KnexJS type definitions work fine in all JS files where I import/require it. But in migrations there is no import/require due to no need of knex initializaion. Type definitions help avoiding error in properties and methods. How can I get type definitions in migration files for KnexJS then?
exports.up = function(knex) {
// type definitions dont work here
};
exports.down = function(knex) {
};
Well. AlhamduLILLAH. I found the answer myself.
/** @typedef {import('knex/types').Knex} knex */
/**
*
* @param {knex} knex
*/
export const up = async knex => {
// Start here.. types work here!!
}
/**
*
* @param {knex} knex
*/
export const down = async knex => {
// Start here.. types work here!!
}