Skip to content

noImplicitAny+prototype assignment causes incorrect error on prototype methods #26923

@sandersn

Description

@sandersn

Note that this is only true with noImplicitAny on. The bug does not manifest with it off.
This is a regression in 3.1. It does not manifest in 3.0.

// @noImplicitAny: true
/** @constructor */
var Multimap = function() {
    this._map = {};
};

Multimap.prototype = {
  x() { }
}

Multimap.prototype.lol = function() {
}

var mm = new Multimap();
mm._map
mm.x
mm.lol

Expected behavior:
No error on Multimap.prototype.lol, and _map, x and lol are properties on Multimap.

Actual behavior:
Error: 'lol' does not exist on type '{ x(): void }'. But all 3 are properties on Multimap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specifically

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions