Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Unified Diff: ui/webui/resources/js/load_time_data.js

Issue 405743002: Typecheck some of ui/webui/resources/js/ with Closure compiler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cr.isMac fix Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/webui/resources/js/i18n_template_no_process.js ('k') | ui/webui/resources/js/local_strings.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/load_time_data.js
diff --git a/ui/webui/resources/js/load_time_data.js b/ui/webui/resources/js/load_time_data.js
index 33b388094bc5cbdd3af870c9eef9c531af814f29..d7f99e161a251e3df8eabe38cc7f9f63cadf6d16 100644
--- a/ui/webui/resources/js/load_time_data.js
+++ b/ui/webui/resources/js/load_time_data.js
@@ -12,12 +12,14 @@
var loadTimeData;
+// Expose this type globally as a temporary work around until
+// https://github.com/google/closure-compiler/issues/544 is fixed.
+/** @constructor */
+function LoadTimeData() {}
+
(function() {
'use strict';
- function LoadTimeData() {
- }
-
LoadTimeData.prototype = {
/**
* Sets the backing object.
@@ -29,6 +31,7 @@ var loadTimeData;
},
/**
+ * @param {string} id An ID of a value that might exist.
* @return {boolean} True if |id| is a key in the dictionary.
*/
valueExists: function(id) {
@@ -55,20 +58,21 @@ var loadTimeData;
getString: function(id) {
var value = this.getValue(id);
expectIsType(id, value, 'string');
- return value;
+ return /** @type {string} */ (value);
},
/**
* Returns a formatted localized string where $1 to $9 are replaced by the
* second to the tenth argument.
* @param {string} id The ID of the string we want.
- * @param {...string} The extra values to include in the formatted output.
+ * @param {...string} var_args The extra values to include in the formatted
+ * output.
* @return {string} The formatted string.
*/
- getStringF: function(id) {
+ getStringF: function(id, var_args) {
var value = this.getString(id);
if (!value)
- return;
+ return '';
var varArgs = arguments;
return value.replace(/\$[$1-9]/g, function(m) {
@@ -84,7 +88,7 @@ var loadTimeData;
getBoolean: function(id) {
var value = this.getValue(id);
expectIsType(id, value, 'boolean');
- return value;
+ return /** @type {boolean} */ (value);
},
/**
@@ -96,7 +100,7 @@ var loadTimeData;
var value = this.getValue(id);
expectIsType(id, value, 'number');
expect(value == Math.floor(value), 'Number isn\'t integer: ' + value);
- return value;
+ return /** @type {number} */ (value);
},
/**
« no previous file with comments | « ui/webui/resources/js/i18n_template_no_process.js ('k') | ui/webui/resources/js/local_strings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698