Skip to content

In JS, can't resolve properties from prototype assignment #26885

@sandersn

Description

@sandersn
function Multimap() {
    this._map = {};
};

Multimap.prototype = {
    /**
     * @param {string} key
     * @returns {number} the value ok
     */
    get(key) {
        return this._map[key + ''];
    }
}

/** @type {Multimap} */
const map = new Multimap();
const n = map.get('hi')

Expected behavior:
No error on map.get

Actual behavior:
Error: 'get' not found on type 'Multimap'

I thought there were tests that covered exactly this case, but apparently not. This doesn't work in 3.0 or 3.1.

Metadata

Metadata

Assignees

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