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

build-optimizer: enum wrapping pass is unsafe in atypical use cases #234

@clydin

Description

@clydin

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request

Area

- [X] devkit
- [ ] schematics

Versions

Repro steps

An enum member can contain an initializer which may have side effects. Currently all enums are wrapping in an IIFE and annotated with PURE which will prevent the side effects from occurring if the enum is unused.

function getValue() {
  console.log('hi');
  return 6;
}

enum Test {
  ValueA,
  ValueB = getValue()
}

Desired functionality

As this will most likely be an extremely rare occurrence, a documentation note may suffice. Additionally a warning or informational message may also be useful when an enum is encountered with a member containing a non-constant expression.

Mention any other details that might be useful

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions