aboutsummaryrefslogtreecommitdiff
path: root/js/map.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/map.js')
-rw-r--r--js/map.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/js/map.js b/js/map.js
index 4f562dbc..7b5b2c38 100644
--- a/js/map.js
+++ b/js/map.js
@@ -48,9 +48,9 @@ goog.forwardDeclare('jspb.BinaryWriter');
*
* @template K, V
*
- * @param {!Array<!Array<!Object>>} arr
+ * @param {!Array<!Array<?>>} arr
*
- * @param {?function(new:V)|function(new:V,?)=} opt_valueCtor
+ * @param {?function(new:V, ?=)=} opt_valueCtor
* The constructor for type V, if type V is a message type.
*
* @constructor
@@ -118,7 +118,7 @@ jspb.Map.prototype.toArray = function() {
strKeys.sort();
for (var i = 0; i < strKeys.length; i++) {
var entry = this.map_[strKeys[i]];
- var valueWrapper = /** @type {!Object} */ (entry.valueWrapper);
+ var valueWrapper = /** @type {?jspb.Message} */ (entry.valueWrapper);
if (valueWrapper) {
valueWrapper.toArray();
}
@@ -136,7 +136,7 @@ jspb.Map.prototype.toArray = function() {
*
* @param {boolean=} includeInstance Whether to include the JSPB instance for
* transitional soy proto support: http://goto/soy-param-migration
- * @param {!function((boolean|undefined),!V):!Object=} valueToObject
+ * @param {!function((boolean|undefined),V):!Object=} valueToObject
* The static toObject() method, if V is a message type.
* @return {!Array<!Array<!Object>>}
*/
@@ -146,7 +146,7 @@ jspb.Map.prototype.toObject = function(includeInstance, valueToObject) {
for (var i = 0; i < rawArray.length; i++) {
var entry = this.map_[rawArray[i][0].toString()];
this.wrapEntry_(entry);
- var valueWrapper = /** @type {!V|undefined} */ (entry.valueWrapper);
+ var valueWrapper = /** @type {V|undefined} */ (entry.valueWrapper);
if (valueWrapper) {
goog.asserts.assert(valueToObject);
entries.push([entry.key, valueToObject(includeInstance, valueWrapper)]);
@@ -165,7 +165,7 @@ jspb.Map.prototype.toObject = function(includeInstance, valueToObject) {
*
* @template K, V
* @param {!Array<!Array<!Object>>} entries
- * @param {!function(new:V)|function(new:V,?)} valueCtor
+ * @param {!function(new:V,?=)} valueCtor
* The constructor for type V.
* @param {!function(!Object):V} valueFromObject
* The fromObject function for type V.
@@ -412,8 +412,8 @@ jspb.Map.prototype.has = function(key) {
* @param {!jspb.BinaryWriter} writer
* @param {!function(this:jspb.BinaryWriter,number,K)} keyWriterFn
* The method on BinaryWriter that writes type K to the stream.
- * @param {!function(this:jspb.BinaryWriter,number,V)|
- * function(this:jspb.BinaryReader,V,?)} valueWriterFn
+ * @param {!function(this:jspb.BinaryWriter,number,V,?=)|
+ * function(this:jspb.BinaryWriter,number,V,?)} valueWriterFn
* The method on BinaryWriter that writes type V to the stream. May be
* writeMessage, in which case the second callback arg form is used.
* @param {function(V,!jspb.BinaryWriter)=} opt_valueWriterCallback
@@ -432,7 +432,8 @@ jspb.Map.prototype.serializeBinary = function(
valueWriterFn.call(writer, 2, this.wrapEntry_(entry),
opt_valueWriterCallback);
} else {
- valueWriterFn.call(writer, 2, entry.value);
+ /** @type {function(this:jspb.BinaryWriter,number,?)} */ (valueWriterFn)
+ .call(writer, 2, entry.value);
}
writer.endSubMessage();
}
@@ -475,10 +476,13 @@ jspb.Map.deserializeBinary = function(map, reader, keyReaderFn, valueReaderFn,
} else if (field == 2) {
// Value.
if (map.valueCtor_) {
+ goog.asserts.assert(opt_valueReaderCallback);
value = new map.valueCtor_();
valueReaderFn.call(reader, value, opt_valueReaderCallback);
} else {
- value = valueReaderFn.call(reader);
+ value =
+ (/** @type {function(this:jspb.BinaryReader):?} */ (valueReaderFn))
+ .call(reader);
}
}
}
@@ -509,7 +513,7 @@ jspb.Map.prototype.stringKeys_ = function() {
/**
- * @param {!K} key The entry's key.
+ * @param {K} key The entry's key.
* @param {V=} opt_value The entry's value wrapper.
* @constructor
* @struct