Skip to content

Bug for this-type in literal object type #6315

Closed
@andy-hanson

Description

@andy-hanson

This code causes an error:

type X<A> = {x: A}

interface Foo {
    // works
    a(): X<this>
    // does not work
    b(): {x: this}
}

Output:

foo.ts(7,11): error TS2526: A 'this' type is available only in a non-static member of a class or interface.

It errors if the object type is defined inline, but works for a typedef.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions