Skip to content

Commit

Permalink
Assert that number|string union is number
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joeyparrish committed Apr 29, 2020
1 parent c5b292a commit 50bf467
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/dash/mpd_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 50bf467

Please sign in to comment.