google / google/closure-compiler

Allow marking @record types as @final to disallow undeclared fields

Open
#1,696 4 comments 1 reaction 0 assignees View on GitHub
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

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.