google / google/closure-compiler
Method return type lost when extending interface
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Briefly:
Interface A has a method with return type "!Object"
Interface B extends Interface A
When calling "toJSON" on intance that implements Interface B, compiler infers return type "*"
Please see the warning in this example:
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%250A%250A%252F**%250A%2520*%2520%2540interface%250A%2520*%252F%250Aclass%2520Interface%2520%257B%250A%2520%2520%252F**%2520%2540return%2520%257B!Object%257D%2520*%252F%250A%2520%2520toJSON()%2520%257B%257D%250A%257D%250A%250A%252F**%250A%2520*%2520%2540interface%250A%2520*%2520%2540extends%2520%257BInterface%257D%250A%2520*%252F%250Aclass%2520Interface2%2520%257B%250A%250A%257D%250A%250A%252F**%250A%2520*%2520%2540implements%2520%257BInterface2%257D%250A%2520*%252F%250Aclass%2520Class%2520%257B%250A%2520%2520%252F**%250A%2520%2520%2520*%2520%2540inheritDoc%250A%2520%2520%2520*%250A%2520%2520%2520*%2520%2540return%2520%257B!Object%257D%250A%2520%2520%2520*%252F%250A%2520%2520toJSON()%250A%2520%2520%257B%250A%2520%2520%2520%2520return%2520%257B%257D%253B%250A%2520%2520%257D%250A%257D%250A%250A%252F**%250A%2520*%2520%2540return%2520%257BInterface2%257D%250A%2520*%252F%250Afunction%2520getInstance()%2520%257B%250A%2520%2520return%2520new%2520Class()%253B%250A%257D%250A%250Avar%2520instance%2520%253D%2520getInstance()%250Avar%2520%252F**%2520!Object%2520*%252Fjson%2520%253D%2520instance.toJSON()%253B%250A%250Aconsole.log(json)%253B
Contributor guide
Assessment
This issue has not been assessed yet.