google / google/closure-compiler

`@const` fields should be overrideable in subclasses

Open
#2,317 1 comment 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

The following seems reasonable to me, but currently runs afoul of the const checker.

```js
class Base {}
/** @const {number} */
Base.prototype.foo = 0;

class Derived extends Base {
constructor(/** number */ foo) {
/** @const */
this.foo = foo;
}
}
```

The error can be suppressed with `@suppress {const}` on the field assignment, but it doesn't seem like that should be required.

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.