Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
UselessPickles opened this issue Dec 10, 2017 · 0 comments
Closed
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@UselessPickles
Copy link

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

@ghost ghost added the Bug A bug in TypeScript label Dec 11, 2017
@ghost ghost self-assigned this Dec 11, 2017
@ghost ghost added the Fixed A PR has been merged for this issue label Dec 11, 2017
@ghost ghost closed this as completed in #20616 Dec 18, 2017
@mhegazy mhegazy added this to the TypeScript 2.7 milestone Jan 11, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants