Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 738b233

Browse filesBrowse files
clydindylhunn
authored andcommitted
fix(core): 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
1 parent cd8b1a5 commit 738b233
Copy full SHA for 738b233

File tree

Expand file treeCollapse file tree

3 files changed

+3
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+3
-3
lines changed

‎packages/core/src/di/injector.ts

Copy file name to clipboardExpand all lines: packages/core/src/di/injector.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const INJECTOR_IMPL = INJECTOR_IMPL__PRE_R3__;
5959
*/
6060
export abstract class Injector {
6161
static THROW_IF_NOT_FOUND = THROW_IF_NOT_FOUND;
62-
static NULL: Injector = new NullInjector();
62+
static NULL: Injector = /* @__PURE__ */ new NullInjector();
6363

6464
/**
6565
* Retrieves an instance from the injector based on the provided token.

‎packages/core/src/di/reflective_injector.ts

Copy file name to clipboardExpand all lines: packages/core/src/di/reflective_injector.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export abstract class ReflectiveInjector implements Injector {
270270
}
271271

272272
export class ReflectiveInjector_ implements ReflectiveInjector {
273-
private static INJECTOR_KEY = ReflectiveKey.get(Injector);
273+
private static INJECTOR_KEY = /* @__PURE__ */ ReflectiveKey.get(Injector);
274274
/** @internal */
275275
_constructionCounter: number = 0;
276276
/** @internal */

‎packages/core/src/linker/component_factory_resolver.ts

Copy file name to clipboardExpand all lines: packages/core/src/linker/component_factory_resolver.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ of the code in this cookbook
4646
* @publicApi
4747
*/
4848
export abstract class ComponentFactoryResolver {
49-
static NULL: ComponentFactoryResolver = new _NullComponentFactoryResolver();
49+
static NULL: ComponentFactoryResolver = /* @__PURE__ */ new _NullComponentFactoryResolver();
5050
/**
5151
* Retrieves the factory object that creates a component of the given type.
5252
* @param component The component type.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.