google / google/closure-compiler
Sometimes failing to typecheck template parameters inside record types
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
The following code does not cause a warning even though `Foo.prototype.foo`'s return type appears to be incorrect.
``` javascript
/**
* @interface
* @template T
*/
function Int() {}
/** @return {{prop: T}} */
Int.prototype.foo = function() {};
/**
* @constructor
* @implements {Int}
*/
function Foo() {}
/**
* @return {{prop: number}} // Should be {prop: string}, but no warning
* @override
*/
Foo.prototype.foo = function() {}
```
https://closure-compiler-debugger.appspot.com/#input0%3D%252F**%250A%2520*%2520%2540interface%250A%2520*%2520%2540template%2520T%250A%2520*%252F%250Afunction%2520Int()%2520%257B%257D%250A%250A%252F**%2520%2540return%2520%257B%257Bprop%253A%2520T%257D%257D%2520*%252F%250AInt.prototype.foo%2520%253D%2520function()%2520%257B%257D%253B%250A%250A%252F**%250A%2520*%2520%2540constructor%250A%2520*%2520%2540implements%2520%257BInt%253Cstring%253E%257D%250A%2520*%252F%250Afunction%2520Foo()%2520%257B%257D%250A%250A%252F**%250A%2520*%2520%2540return%2520%257B%257Bprop%253A%2520number%257D%257D%2520%252F%252F%2520Should%2520be%2520%257Bprop%253A%2520string%257D%2520%253F%253F%250A%2520*%2520%2540override%250A%2520*%252F%250AFoo.prototype.foo%2520%253D%2520function()%2520%257B%257D%26input1%26conformanceConfig%26externs%26refasterjs-template%26CHECK_SYMBOLS%3Dtrue%26MISSING_PROPERTIES%3Dtrue%26TRANSPILE%3Dtrue%26CHECK_TYPES%3Dtrue%26CLOSURE_PASS%3Dtrue%26PRESERVE_TYPE_ANNOTATIONS%3Dtrue%26PRETTY_PRINT%3Dtrue
Contributor guide
Assessment
This issue has not been assessed yet.