Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GustavoSabel opened this issue Mar 20, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@GustavoSabel
Copy link

GustavoSabel commented Mar 20, 2024

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

@LookinGit
Copy link
Member

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

@GustavoSabel
Copy link
Author

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

@GustavoSabel
Copy link
Author

When Post uses SoftDeletes
image

When Post doesn't use SoftDeletes
image

@LookinGit
Copy link
Member

Yep, bug into incorrect type of mixin

@LookinGit LookinGit added the bug Something isn't working label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants