Not emitting types in externs can cause misoptimization, consider making it an error #1070
Description
Example comes from issue #1067:
declare interface Something {
myProp: string & {other: string};
}
Because it cannot represent intersection types to Closure Compiler, tsickle will emit something like:
/** @fileoverview @externs */
/** @record */
function Something() {}
/** @type {?} */
Something.prototype.myProp;
Observe that the externs file now contains no mention of a property other
, so Closure Compiler will most likely happily rename it if it encounters the property in your program. Ouch.
Depending on host configuration, we do print a warning when encountering this, but warnings are typically hard to find for users in large builds. Emitting a comment in the source text also doesn't help much, as few people will read their generated externs sources.
Given the high stakes in externs, we could consider erroring out instead of emitting a warning in this case. However this might break using many .d.ts
files with tsickle, so we need to balance the impact here.
/CC @engelsdamien