google / google/closure-compiler
Compiler ignores object type if any attribute has dynamic name
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
See code below.
`anObject.shoudValidate()` has a non-null parameter.
It's called in `foobar()` with an optional one, but the compiler doesn't complain.
If you comment the dynamic attribute `['someOtherName']`, then the compilation fails.
```javascript
// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level ADVANCED_OPTIMIZATIONS
// ==/ClosureCompiler==
const anObject = {
/** @param {string} requiredValue */
shouldValidate: function(requiredValue) {},
['someOtherName']: function() {},
};
/** @param {?string} optionalValue */
function foobar(optionalValue) {
anObject.shouldValidate(optionalValue);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.