Skip to content

How to annotate a symbol outside the location of definition? #3191

@juj

Description

@juj

When developing Closure minification support to Emscripten compiler, there is a need to annotate some symbols with e.g. @suppress {undefinedVars} or @suppress {duplicate}.

If I use an --externs file to specify an annotation, e.g. --externs externs.js, with

/**
 * @suppress {duplicate}
 */
var foo;

then not only does Closure take in the annotation, but it also then will no longer minify foo, because it is being specified in an externs file.

If I use a --js file before the main JS file to specify an annotation, e.g. --js annotation.js --js main.js, with

/**
 * @suppress {duplicate}
 */
var foo;

then Closure will want to add (in some scenarios, not quite sure when this occurs) a top level global dummy variable var a; in the beginning of the Closured output file, that takes up redundant space and bloats the final output.

What I'd like to do is specify a --annotations annotations.js file that would not prevent minification like externs does, but neither will cause dummy symbols being defined to the build output, like --js does. Is this possible somehow with current Closure?

Metadata

Metadata

Assignees

No one assigned

    Labels

    internal-issue-createdAn internal Google issue has been created to track this GitHub issuetriage-doneHas been reviewed by someone on triage rotation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions