From 50bf4670555efc5356fb53d5b5c914205109f405 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Wed, 29 Apr 2020 12:37:11 -0700 Subject: [PATCH] Assert that number|string union is number The new Closure Compiler complains that a number|string union from a map in MpdUtils is used in a calculation. In practice, we know that this specific value is always a number, so we add an assertion to satisfy the newer compiler's type checks. Issue #2528 Change-Id: Id12de47d2dd4a12f9cc35879bee8da5ee25cdd70 --- lib/dash/mpd_utils.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dash/mpd_utils.js b/lib/dash/mpd_utils.js index e4bb3e3f6e..f7b84657fa 100644 --- a/lib/dash/mpd_utils.js +++ b/lib/dash/mpd_utils.js @@ -69,6 +69,8 @@ shaka.dash.MpdUtils = class { } if (name == 'Time') { + goog.asserts.assert(typeof value == 'number', + 'Time value should be a number!'); goog.asserts.assert(Math.abs(value - Math.round(value)) < 0.2, 'Calculated $Time$ values must be close to integers'); value = Math.round(value);