google / google/closure-compiler
`@record` shouldn't be applied retroactively to aliases
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
In [this example][1] I define two `@interface`s, but in a different module alias one as a `@record`, which "retroactively" changes the original interface into a structural interface. This seems unsafe.
```js
// parent
/** @interface */
function Foo() {}
/** @interface */
function Bar() {}
/** @param {!Foo} arg */
function foo(arg) {}
/** @param {!Bar} arg */
function bar(arg) {}
// child
/** @record */
var Baz = Foo;
foo({});
bar({});
```
Only the error for `bar` is reported, since the `Baz` alias converts `Foo` to be a `@record`.
[1]: https://closure-compiler-debugger.appspot.com/#input0%3D%252F**%2520%2540interface%2520*%252F%250Afunction%2520Foo()%2520%257B%257D%250A%250A%252F**%2520%2540interface%2520*%252F%250Afunction%2520Bar()%2520%257B%257D%250A%250A%252F**%2520%2540param%2520%257B!Foo%257D%2520arg%2520*%252F%250Afunction%2520foo(arg)%2520%257B%257D%250A%250A%252F**%2520%2540param%2520%257B!Bar%257D%2520arg%2520*%252F%250Afunction%2520bar(arg)%2520%257B%257D%26input1%3D%252F**%2520%2540record%2520*%252F%250Avar%2520Baz%2520%253D%2520Foo%253B%250A%250Afoo(%257B%257D)%253B%250Abar(%257B%257D)%253B%26conformanceConfig%26externs%26refasterjs-template%26CHECK_TYPES%3Dtrue%26TRANSPILE%3Dtrue%26PRESERVE_TYPE_ANNOTATIONS%3Dtrue%26PRETTY_PRINT%3Dtrue
Contributor guide
Assessment
This issue has not been assessed yet.