You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to use covariant return type like this, in NTI:
/** @param {Object} obj */varhelper=function(obj){};// in externs/** * @this {THIS} * @return {THIS} * @template THIS */x(){this.something();helper(this);returnthis;}
Warnings generated:
input0:9: WARNING - Cannot access property something of non-object type THIS.
this.something();
^
input0:10: WARNING - Invalid type for parameter 1 of function helper.
expected : Object|null
found : THIS
helper(this);
The right fix for this is to handle bounded generics in NTI. Without that, we probably want to warn here. We don't know anything about the type variable, we don't know if it's an object, or what properties it has. So, without bounded generics, you have to cast for the time being.
Trying to use covariant return type like this, in NTI:
Warnings generated:
I think both should be inferred as valid.
https://closure-compiler-debugger.appspot.com/#input0%3Dclass%2520X%2520%257B%250A%250A%2520%2520%252F**%250A%2520%2520%2520*%2520%2540this%2520%257BTHIS%257D%250A%2520%2520%2520*%2520%2540return%2520%257BTHIS%257D%250A%2520%2520%2520*%2520%2540template%2520THIS%250A%2520%2520%2520*%252F%250A%2520%2520x()%2520%257B%250A%2520%2520%2520%2520this.something()%253B%250A%2520%2520%2520%2520helper(this)%253B%250A%2520%2520%2520%2520return%2520this%253B%250A%2520%2520%257D%250A%250A%2520%2520something()%2520%257B%2520%250A%2520%2520%2520%2520console.log(this)%253B%2520%250A%2520%2520%257D%250A%250A%257D%26input1%26conformanceConfig%26externs%3D%252F**%2520%2540param%2520%257BObject%257D%2520obj%2520*%252F%250Avar%2520helper%2520%253D%2520function(obj)%2520%257B%257D%253B%250A%26refasterjs-template%26includeDefaultExterns%3D1%26CHECK_SYMBOLS%3D1%26CHECK_TYPES%3D1%26CHECK_TYPES_NEW_INFERENCE%3D1%26LANG_IN_IS_ES6%3D1%26MISSING_PROPERTIES%3D1%26PRESERVE_TYPE_ANNOTATIONS%3D1%26PRETTY_PRINT%3D1%26TRANSPILE%3D1
Related to #1411
The text was updated successfully, but these errors were encountered: