lookinlab/adonis-lucid-soft-deletes

Issue with `useTransaction()`. Returning any after upgrading to AdonisJS V6

Opened this issue · 4 comments

After upgrading my application to AdonisJS V6, I've encountered an issue with the useTransaction() method's type definition. In version 5, calling this method preserved the instance type, enabling IntelliSense for subsequent method calls. However, in version 6, useTransaction() returns a type of any, which disrupts IntelliSense and affects code clarity.

Code Example:

const product = await new Product()
  .fill({ /* property values */ })
  .useTransaction(trx) // Now returns `any`, affecting IntelliSense
  .save();

// Here, "product" is inferred as `any`, losing type specificity

Expected Behavior:

In AdonisJS V5, useTransaction() would return the specific type of the instance (e.g., this), allowing for continued IntelliSense support and type safety in chained method calls.

Actual Behavior:

In AdonisJS V6, useTransaction() returns any, leading to a loss of IntelliSense and type safety for any subsequent chained method calls.

Additional Information:

Navigating to the definition of useTransaction() takes me to mixin.d.ts from SoftDeletes, unlike in V5, where it would lead to the LucidRow interface definition in AdonisJS.

Request:

Could the type definition for useTransaction() be adjusted to maintain the instance's type, as in V5, to support IntelliSense and enhance developer experience? Any guidance or workarounds would also be greatly appreciated.

Repository:

I created this repository with the issue: https://github.com/GustavoSabel/issue-soft-deletes-adonisjsv6

The package not overrides useTransaction. Try your code example without package, if the error will remain, need move this issue into lucid repo

I created a repository with the issue: https://github.com/GustavoSabel/issue-soft-deletes-adonisjsv6
The problem doesn't happen If I don't use the SoftDeletes

When Post uses SoftDeletes
image

When Post doesn't use SoftDeletes
image

Yep, bug into incorrect type of mixin