Add some typecast for the closure-compiler

This commit is contained in:
Frederic Junod
2018-03-07 17:07:53 +01:00
parent 3435ac575e
commit 735798a88c
2 changed files with 8 additions and 13 deletions
+3 -5
View File
@@ -126,15 +126,13 @@ export function reverseSubArray(arr, begin, end) {
/** /**
* @param {Array.<VALUE>} arr The array to modify. * @param {Array.<VALUE>} arr The array to modify.
* @param {Array.<VALUE>|VALUE} data The elements or arrays of elements * @param {!Array.<VALUE>|VALUE} data The elements or arrays of elements to add to arr.
* to add to arr.
* @template VALUE * @template VALUE
*/ */
export function extend(arr, data) { export function extend(arr, data) {
let i;
const extension = Array.isArray(data) ? data : [data]; const extension = Array.isArray(data) ? data : [data];
const length = extension.length; const length = extension.length;
for (i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
arr[arr.length] = extension[i]; arr[arr.length] = extension[i];
} }
} }
@@ -160,7 +158,7 @@ export function remove(arr, obj) {
* @param {Array.<VALUE>} arr The array to search in. * @param {Array.<VALUE>} arr The array to search in.
* @param {function(VALUE, number, ?) : boolean} func The function to compare. * @param {function(VALUE, number, ?) : boolean} func The function to compare.
* @template VALUE * @template VALUE
* @return {VALUE} The element found. * @return {VALUE|null} The element found or null.
*/ */
export function find(arr, func) { export function find(arr, func) {
const length = arr.length >>> 0; const length = arr.length >>> 0;
+5 -8
View File
@@ -420,11 +420,10 @@ export function parseNode(parsersNS, node, objectStack, opt_this) {
* @return {T} Object. * @return {T} Object.
* @template T * @template T
*/ */
export function pushParseAndPop( export function pushParseAndPop(object, parsersNS, node, objectStack, opt_this) {
object, parsersNS, node, objectStack, opt_this) {
objectStack.push(object); objectStack.push(object);
parseNode(parsersNS, node, objectStack, opt_this); parseNode(parsersNS, node, objectStack, opt_this);
return objectStack.pop(); return /** @type {T} */ (objectStack.pop());
} }
@@ -491,10 +490,8 @@ export function serialize(
* @return {O|undefined} Object. * @return {O|undefined} Object.
* @template O, T * @template O, T
*/ */
export function pushSerializeAndPop(object, export function pushSerializeAndPop(object, serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this) {
serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this) {
objectStack.push(object); objectStack.push(object);
serialize( serialize(serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this);
serializersNS, nodeFactory, values, objectStack, opt_keys, opt_this); return /** @type {O|undefined} */ (objectStack.pop());
return objectStack.pop();
} }