Skip to content

Custom type guard in getters is broken #7150

@tinganho

Description

@tinganho

TypeScript Version:

nightly

Code

class A {
    get a(): this is A {
        return true
    }
}

Expected behavior:

The getter type guard should not complain

Actual behavior:

tsc
Library/DataStore.ts(55,27): error TS1228: A type predicate is only allowed in return type position for functions and methods.
Library/DataStore.ts(103,20): error TS1228: A type predicate is only allowed in return type position for functions and methods.

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