64ac5a53f4
* check for expando initializers in resolveEntityName when resolving type parameters in a prototype property assignment declaration. For example, this already works: ```js /** @template T */ function f(x) { this.x = x } /** @returns {T} */ f.protototype.m = function () { return this.x } ``` This now works too: ```js /** @template T */ var f = function (x) { this.x = x } /** @returns {T} */ f.prototype.m = function () { return this.x } ``` Fixes #26826 * Lookup type parameters on prototype-assignment methods In the same way that they're looked up on prototype-property methods. That is, this previously worked: ```js /** @template T */ function f() { } /** @param {T} p */ f.prototype.m = function () { } ``` And this now works too: ```js /** @template T */ function f() { } f.prototype = { /** @param {T} p */ m() { } } ``` Note that the baselines still have errors; I'll file a followup bug for them. * Look up types on property assignments too
63 lines
1.2 KiB
TypeScript
63 lines
1.2 KiB
TypeScript
// @noEmit: true
|
|
// @allowJs: true
|
|
// @checkJs: true
|
|
// @strict: true
|
|
// @Filename: a.js
|
|
|
|
/**
|
|
* Should work for function declarations
|
|
* @constructor
|
|
* @template {string} K
|
|
* @template V
|
|
*/
|
|
function Multimap() {
|
|
/** @type {Object<string, V>} TODO: Remove the prototype from the fresh object */
|
|
this._map = {};
|
|
};
|
|
|
|
/**
|
|
* @param {K} key the key ok
|
|
* @returns {V} the value ok
|
|
*/
|
|
Multimap.prototype.get = function (key) {
|
|
return this._map[key + ''];
|
|
}
|
|
|
|
/**
|
|
* Should work for initialisers too
|
|
* @constructor
|
|
* @template {string} K
|
|
* @template V
|
|
*/
|
|
var Multimap2 = function() {
|
|
/** @type {Object<string, V>} TODO: Remove the prototype from the fresh object */
|
|
this._map = {};
|
|
};
|
|
|
|
/**
|
|
* @param {K} key the key ok
|
|
* @returns {V} the value ok
|
|
*/
|
|
Multimap2.prototype.get = function (key) {
|
|
return this._map[key + ''];
|
|
}
|
|
|
|
var Ns = {};
|
|
/**
|
|
* Should work for expando-namespaced initialisers too
|
|
* @constructor
|
|
* @template {string} K
|
|
* @template V
|
|
*/
|
|
Ns.Multimap3 = function() {
|
|
/** @type {Object<string, V>} TODO: Remove the prototype from the fresh object */
|
|
this._map = {};
|
|
};
|
|
|
|
/**
|
|
* @param {K} key the key ok
|
|
* @returns {V} the value ok
|
|
*/
|
|
Ns.Multimap3.prototype.get = function (key) {
|
|
return this._map[key + ''];
|
|
}
|