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

TypeScript: Property does not exist on type #23

Open
Secular12 opened this issue Jul 19, 2024 · 5 comments
Open

TypeScript: Property does not exist on type #23

Secular12 opened this issue Jul 19, 2024 · 5 comments

Comments

@Secular12
Copy link

Secular12 commented Jul 19, 2024

image
When using withTrashed() in Adonis 6, I get Property 'restore' does not exist on type...

This is my User model:

image

I am not sure what could be causing the issue?

This also seems to happen on .withTrashed() when I use .query() ahead of it:

await User.query().withTrashed().where('id', id).firstOrFail()

image

@Secular12 Secular12 changed the title TypeScript restore method error TypeScript: Property does not exist on type Jul 19, 2024
@thansil-emst
Copy link

I am experiencing the same situation. I am not able to use User.query().withTrashed() online working like User.withTrashed().

@CodingDive
Copy link

CodingDive commented Aug 25, 2024

Same problem here, happened after upgrading lucid and typescript

"adonis-lucid-soft-deletes": "^2.1.0",
"typescript": "^5.5.4",
"@adonisjs/lucid": "^21.2.0",

Luckily it's just a type error and everything seems to keep working!

@LookinGit
Copy link
Member

@tavaresgerson
Copy link

Hello devs!

My solutions for this:

    const entity = await Entity.withTrashed().where('id', id).firstOrFail()
    await entity.merge({ deleted_at: null }).save()

I hope help you ☕

@phicoder
Copy link

phicoder commented Jan 4, 2025

Found an issue here

): ModelQueryBuilderContractWithIgnoreDeleted<Model, InstanceType<T>> {

InstanceType<T> should be InstanceType<Model>

This causes the returntype of your query to be LucidRow instead of your model's type. The quickest way to temporarily fix it would be by using https://www.npmjs.com/package/patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants