Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
This repository was archived by the owner on May 22, 2025. It is now read-only.

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

Open
@mprobst

Description

@mprobst

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    typed optimizationsBugs that only cause problems with typed optimizations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions