Skip to content

this keyword as a dynamic return type #147

@Mouvedia

Description

@Mouvedia

related: #68

example

You have a fluent interface but one of the method X is slightly restrictive and doesn't return this but a subset of its this. In this case if the next method Y returns this it will share its constraints.

problem: if that method Y may also follow another method Z that returns this, its return type becomes dynamic.
solution: introduce a this return type

NB

It would be impractical to require the user to provide all the possibilities as unions.
It's the job of the static type checker; it should be able to infer the correct type from the current this.

proposal

example(name: Type) => this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions