fix(animations): add pure annotations to static property initializers (#43064)

Class static properties with initializers that cause code execution (for example, call expressions or new expressions) have the potential to cause side effects at module evaluation. This is similar in effect to module level code. As a result, optimizers can not safely remove a class with such a static property as the potential side effects may have meaningful effects on the state of the application execution. To allow classes with these type of static properties to be optimized and removed if unused, the initializer expressions for the static properties can be annotated as pure. This annotation provides a signal to an optimizer that the expression does not have any potential side effects and is useful in cases where static analysis can not currently prove that there are, in fact, no side effects caused by the initializer.

PR Close #43064
This commit is contained in:
Charles Lyding
2021-08-06 10:27:05 -04:00
committed by Dylan Hunn
parent 27a89a9298
commit 3cb1f18f97
2 changed files with 2 additions and 2 deletions
@@ -47,7 +47,7 @@ export class NoopAnimationDriver implements AnimationDriver {
* @publicApi
*/
export abstract class AnimationDriver {
static NOOP: AnimationDriver = new NoopAnimationDriver();
static NOOP: AnimationDriver = /* @__PURE__ */ new NoopAnimationDriver();
abstract validateStyleProperty(prop: string): boolean;
@@ -44,7 +44,7 @@ export function packageNonAnimatableStyles(
* `destroy()` is called then all styles will be removed.
*/
export class SpecialCasedStyles {
static initialStylesByElement = new WeakMap<any, {[key: string]: any}>();
static initialStylesByElement = /* @__PURE__ */ new WeakMap<any, {[key: string]: any}>();
private _state = SpecialCasedStylesState.Pending;
private _initialStyles!: {[key: string]: any};