-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
The type checker acts like data
is a valid property of any Object type.
closure-compiler-v20160911.jar --jscomp_error=checkTypes --jscomp_error=checkVars --jscomp_error=missingProperties
/** @type {number} e */
function bar(e) {
var a = new Object();
foo(a.data); // No error!
foo(Object.prototype.data); // No error!
foo(a.blah); // ERROR - Property blah never defined on Object
}
/** @type {number} */
function foo(o) { o++; }
Expected: First error on line 4, "Property data never defined on Object"
Actual: First error on line 6, "Property blah never defined on Object"
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Dominator008 commentedon Oct 5, 2016
Yeah. OTI isn't strict enough about missing properties. NTI will address this:
https://closure-compiler-debugger.appspot.com/#input0%3D%252F**%2520%2540param%2520%257Bnumber%257D%2520e%2520*%252F%250Afunction%2520bar(e)%2520%257B%250A%2520%2520var%2520a%2520%253D%2520new%2520Object()%253B%250A%2520%2520foo(a.data)%253B%2520%2520%252F%252F%2520No%2520error!%250A%2520%2520foo(Object.prototype.data)%253B%2520%2520%252F%252F%2520No%2520error!%250A%2520%2520foo(a.blah)%253B%2520%2520%252F%252F%2520ERROR%2520-%2520Property%2520blah%2520never%2520defined%2520on%2520Object%250A%257D%250A%250A%252F**%2520%2540param%2520%257Bnumber%257D%2520o%2520*%252F%250Afunction%2520foo(o)%2520%257B%2520o%252B%252B%253B%2520%257D%26input1%26conformanceConfig%26externs%26refasterjs-template%26includeDefaultExterns%3D1%26CHECK_TYPES_NEW_INFERENCE%3D1%26PRESERVE_TYPE_ANNOTATIONS%3D1%26PRETTY_PRINT%3D1