-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Not sure if this belongs in closure-library or closure-compiler.
When compiling closure-library with --jscomp_error=checkTypes using JDK 8, the compiler errors on this code:
closure/goog/dom/abstractrange.js:79: ERROR - Property item never defined on range
} else if (!range.length || range.item(0).document != doc) {
^
Modifying the code to:
diff --git a/closure/goog/dom/abstractrange.js b/closure/goog/dom/abstractrange.js
--- a/closure/goog/dom/abstractrange.js
+++ b/closure/goog/dom/abstractrange.js
@@ -76,7 +76,7 @@ goog.dom.AbstractRange.getBrowserSelectionForWindow = function(win) {
if (range.parentElement().document != doc) {
return null;
}
- } else if (!range.length || range.item(0).document != doc) {
+ } else if (!range.length || /** @type {ControlRange} */ (range).item(0).document != doc) {
// For ControlRanges, check that the range has items, and that
// the first item in the range is in the correct document.
return null;
Solves the problem.
I have no idea why type inference works with JDK < 8 in this case.