google / google/closure-compiler

TypeCheck.INEXISTENT_PROPERTY being reported incorrectly

Open
#2,165 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Since updating (I was previously using a mid-summer build), I'm getting `JSC_INEXISTENT_PROPERTY` for subsequent access to properties defined in a class constructor.

It only occurs in NTI when `options.setReportOTIErrorsUnderNTI(true)`. An obscure option, I know, also one I added myself, and admittedly I'm probably the only one using it.

Without NTI, the error does not occur.
With NTI and `options.setReportOTIErrorsUnderNTI(false)` the error does not occur.
Only with NTI and `options.setReportOTIErrorsUnderNTI(true)` does the error occur.

Externs:
``` javascript
/**
* @constructor
*/
var RC = function() {};
```
Class:
``` javascript
export default class S extends RC {
constructor() {
super();
this.e = "eee";
}
m() {
console.log(this.e);
}
}
```
Warning:
```
S.js:7: WARNING - Property e never defined on S
5| }
6| m() {
7| console.log(this.e);
8| }
9| }
```

Is `TypeCheck.INEXISTENT_PROPERTY` an OTI-specific error? Is `TypeCheck` itself OTI specific? I didn't think it was. If it is, I just need to filter out the warning. If not, it's possibly a bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.