google / google/closure-compiler
Allow marking @record types as @final to disallow undeclared fields
Open
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Use case: "keyword" arguments to functions. It would be wonderful to get an error for a typo-ed optional argument key.
``` js
/** @record @final */ const ExtraArgs = function() {};
/** @type {!string|undefined} */ ExtraArgs.prototype.foo;
```
Then `{}` and `{foo: 'bar'}` would both match, but `{fop: 'bar'}` would fail to match because the interface is sealed and `fop` isn't a known field.
Contributor guide
Assessment
This issue has not been assessed yet.