diff --git a/js/common/ChipperStringUtils.js b/js/common/ChipperStringUtils.js index bccd1e83b..af606a8f9 100644 --- a/js/common/ChipperStringUtils.js +++ b/js/common/ChipperStringUtils.js @@ -154,6 +154,9 @@ if ( result.value === undefined ) { throw new Error( `no value for string: ${key}` ); } + if ( typeof result.value !== 'string' ) { + throw new Error( `value should be a string for key ${key}` ); + } return result.value; } @@ -162,10 +165,9 @@ }, /** - * Call a function on each string object in a string map. Recursively dive into each object that doesn't have a - * `value` to find nested string objects too. - * @param {StringMap} map - string map, like a loaded JSON strings file - * @param {function(key:string, StringObject)} func + * Call a function on each object with a value attribute in an object tree. + * @param {Object.} map - string map, like a loaded JSON strings file + * @param {function(key:string, {value:string})} func * @public */ forEachString( map, func ) {