I have some code:
await db.transaction(async (trx) => {
...
})
inside of that block i need to pass trx to functions, i do so like this:
const items = await Items.fetchAll({ trx })
sometimes like in this case its totally fine.
static async fetchAll ({ trx = db }): Promise<Array<any>> {
...
}
in cases where i type the destructure like so:
static async updateCharacterEquipment ({ character, items, charID, incursionID, trx = db } : { character : Character, items : Array<Item>, charID : number, incursionID : number, trx : any }): Promise<void> {
...
}
I get errors:
character/index.character.ts(59,38): error TS7006: Parameter 'trx' implicitly has an 'any' type.
character/index.character.ts(58,46): error TS7031: Binding element 'character' implicitly has an 'any' type.
character/index.character.ts(58,57): error TS7031: Binding element 'items' implicitly has an 'any' type.
character/index.character.ts(58,64): error TS7031: Binding element 'charID' implicitly has an 'any' type.
character/index.character.ts(58,72): error TS7031: Binding element 'incursionID' implicitly has an 'any' type.
Not sure how to handle these errors, and i dont know how to get the Knex.Transaction type so that I can properly type the trx