Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not emitting types in externs can cause misoptimization, consider making it an error #1070

Open
mprobst opened this issue Sep 11, 2019 · 0 comments
Labels
typed optimizations Bugs that only cause problems with typed optimizations

Comments

@mprobst
Copy link
Contributor

mprobst commented Sep 11, 2019

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

@evmar evmar added the typed optimizations Bugs that only cause problems with typed optimizations label Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typed optimizations Bugs that only cause problems with typed optimizations
Projects
None yet
Development

No branches or pull requests

2 participants