boolean expectNotNullOrUndefined ( NodeTraversal t , Node n , JSType type , String msg , JSType expectedType ) { if ( ! type . isNoType ( ) && ! type . isUnknownType ( ) && type . isSubtypeOf ( nullOrUndefined ) && ! containsForwardDeclaredUnresolvedName ( type ) ) { // There's one edge case right now that we don't handle well, and // that we don't want to warn about. // if (this.x == null) { // this.initializeX(); // this.x.foo(); // } // In this case, we incorrectly type x because of how we // infer properties locally. See issue 109. // http://blickly.github.io/closure-compiler-issues/#109 // // We do not do this inference globally. if ( n . isGetProp ( ) && ! t . inGlobalScope ( ) && type . isNullType ( ) ) { return true ; } mismatch ( n , msg , type , expectedType ) ; return false ; } return true ; }
Expect the type to be anything but the null or void type . If the expectation is not met issue a warning at the provided node s source code position . Note that a union type that includes the void type and at least one other type meets the expectation .