Closed
Description
🚀 Feature request
Description
Using the ES2015 target, TypeScript transpiles enums as consts plus property assignments.
As an example, the ChangeDetectionStrategy
enum in https://github.com/angular/angular/blob/13eb57a59fd4db27e88edb188947297b6637177f/packages/compiler/src/core.ts#L82-L85:
export enum ChangeDetectionStrategy {
OnPush = 0,
Default = 1
}
Is transpiled to ES2015 as:
const ChangeDetectionStrategy = {
OnPush: 0,
Default: 1
};
ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
The property assignment in the transpiled code prevents the class from being removed by minifiers such as terser.
Describe the solution you'd like
Build Optimizer converts ES2015 enums in such a way that they are not retained after minification.