Skip to content

this is no longer any in functions of object literal assigned to prototype #1782

@dragomirtitian

Description

@dragomirtitian

Steps to reproduce

function Stream() {
}

Stream.prototype = {
    endOfStream: function (): boolean {
        return !this.tokens.length;
    },
};

Playground Link

Behavior with [email protected]

this was any so this.tokens was not an error.

Behavior with tsgo

this is typed as { endOfStream: () => any; } resulting in an error on this.tokens

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Type CheckingRelated to type checking, grammar checking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions