Skip to content

Standard JSDoc annotations for Pure/Unpure #3122

Description

@indo-dev-0

Actual Behavior / Situation

Rollup and Terser can use the annotations /*@__PURE__*/ and /*#__PURE__*/ to mark functions as pure or impure.

Rollup, WebPack, and Terser can also declare purity of entire files using sideEffects and usedExports declarations in a config file or package.json.

Expected Behavior / Situation

Usage of standard JSDoc annotations to specify function purity.

Google Closure Compiler uses @nosideeffects and @modifies {this|arguments} annotations to specify a function's state mutation. They do, however, have to be defined using an extern.

Modification Proposal

Replace /*@__PURE__*/ and /*#__PURE__*/ with @nosideeffects and @modifies {this|arguments} annotations. This is more accurate, idiomatic, and more finely grained than the current approaches.

P.S. You might also be interested in @noalias, @nocompile, @nocollapse, @noinline, or @private.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions