Skip to content

Intellisense suggests methods with mismatched "this" parameter types #20608

Closed
@UselessPickles

Description

@UselessPickles

TypeScript Version: 2.6.2

Code

class ValueWrapper<T> {
    constructor(private readonly value: T) {}

    public getValue(): T {
        return this.value;
    }

    public isZero(this: ValueWrapper<number>): boolean {
        return this.value === 0;
    }
}

const stringWrapper = new ValueWrapper<string>("hello");
const numberWrapper = new ValueWrapper<number>(42);

Expected behavior:

Intellisense should only suggest the isZero method on numberWrapper, but not for stringWrapper.

Actual behavior:

Intellisense does not filter out suggestions based on this param types.
(screenshot from the Typescript Playground)

suggest

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions