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

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

Issue 443553002: Typecheck chrome://help using CompilerPass.java, everything except dependency to options (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@true_master
Patch Set: rebase to master, compile everything but dependency to options 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
Index: ui/webui/resources/js/assert.js
diff --git a/ui/webui/resources/js/assert.js b/ui/webui/resources/js/assert.js
index 7b38398ed0175179cfc6efaf510b489a73bbf591..563b12ec4bfe63b4dc6815e8d1c5cb706581aaf4 100644
--- a/ui/webui/resources/js/assert.js
+++ b/ui/webui/resources/js/assert.js
@@ -47,3 +47,16 @@ function assert(condition, opt_message) {
function assertNotReached(opt_message) {
throw new Error(opt_message || "Unreachable code hit");
}
+
+/**
+ * @param {*} value The value to check.
+ * @param {function(new: T, ...)} type A user-defined constructor.
+ * @return {!T}
+ * @template T
+ */
+function assertInstanceof(value, type) {
+ if (!(value instanceof type)) {
Dan Beam 2014/08/13 22:20:08 nit: no curlies
Vitaly Pavlenko 2014/08/14 00:01:02 Done.
+ throw new Error('assertInstanceof');
Dan Beam 2014/08/13 22:20:07 throw new Error(value + ' is not a[n] ' + (type.na
Vitaly Pavlenko 2014/08/14 00:01:02 Done.
+ }
+ return value;
+}

Powered by Google App Engine
This is Rietveld 408576698