google / google/closure-compiler
Extending a class does not warn when constructed with the wrong type
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
I would expect:
```js
class Foo {
/** @param {string} baz */
constructor(baz) {
/** @type {string} */
this.banana = baz
}
}
class Bar extends Foo {}
new Foo(1);
new Foo('1');
new Bar(1);
new Bar('1');
```
to give me 2 warnings. But, I only get one warning for `new Foo(1);`. It lets me call `new Bar(1);` with the wrong type.
https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250Aclass%2520Foo%2520%257B%250A%2520%2520%252F**%2520%2540param%2520%257Bstring%257D%2520baz%2520*%252F%250A%2520%2520constructor(baz)%2520%257B%250A%2520%2520%2520%2520%252F**%2520%2540type%2520%257Bstring%257D%2520*%252F%250A%2520%2520%2520%2520this.banana%2520%253D%2520baz%250A%2520%2520%257D%250A%257D%250A%250Aclass%2520Bar%2520extends%2520Foo%2520%257B%257D%250A%250Anew%2520Foo(1)%253B%250Anew%2520Foo('1')%253B%250Anew%2520Bar(1)%253B%250Anew%2520Bar('1')%253B%250A
Contributor guide
Assessment
This issue has not been assessed yet.