Skip to content

Not able to make a Thenable Class #63

Closed
@shiny

Description

@shiny

Package version

@adonisjs/[email protected]

Describe the bug

This is a simple Thenable Class Example

class Database {
    where() {
        return this
    }
    and() {
        return this
    }
    limit() {
        return this
    }
    then(onFulfilled: (result: string) => any) {
        onFulfilled('my example result')
    }
}

What I expect is

const db = await app.container.make(Database)
const result = await db.where().and().limit()
result === 'my example result''

But the result is db === 'my example result', not a instance of Database.
The thenable class is useful for graceful chain methods

Reproduction repo

https://github.com/shiny/reproduce-thenable-class-issue/blob/main/tests/unit/example.spec.ts

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions