Skip to content
Permalink
Browse files
fix(core): emit pure annotations to static property initializers (#43344
)

Currently the pure annotations comments are not emitted because unless the entire expression is wrapped in braces.

See the below TypeScript playgrounds

https://www.typescriptlang.org/play?target=99&module=1&ts=4.4.2&ssl=8&ssc=1&pln=1&pc=1#code/MYGwhgzhAEByCuIQEkB2ArApsALgewCdoBvAXwFgAoKzADwAdCdowAjCHAsXaUSGNFlyESVaNA5gcAS2BwAqgBlF0ALzQA9ACpoAAQD6+gAryASgFFD0LRuipMAdziIUGbPgIAKAJQBuKhTUlMB4qBB4IJgAdCB4AOaegu6EUbBKin5UQA
```js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Injector = void 0;
class NullInjector {
}
class Injector {
}
exports.Injector = Injector;
Injector.NULL = new NullInjector();
console.log(Injector.NULL);

```

https://www.typescriptlang.org/play?target=99&module=1&ts=4.4.2&ssl=4&ssc=18&pln=4&pc=33#code/MYGwhgzhAEByCuIQEkB2ArApsALgewCdoBvAXwFgAoKzADwAdCdowAjCHAsXaUSGNFlyESVaNA5gcAS2BwAqgBlF0ALzQAFAHoAVNAACAfUMAFeQCUAoseg6t0VJgDucRCgzZ8BDQEofAbioKakpgPFQIPBBMADoQPABzDUFPQhjYJUUAqiA

```js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Injector = void 0;
class NullInjector {
}
class Injector {
}a
exports.Injector = Injector;
Injector.NULL = ( /* @__PURE__ */new NullInjector());
console.log(Injector.NULL);
```

PR Close #43344
  • Loading branch information
alan-agius4 authored and AndrewKushnir committed Sep 9, 2021
1 parent 0e14dee commit ca510c87c5a890c4b22fd364c58667adef90a1e0
Showing with 3 additions and 3 deletions.
  1. +1 −1 packages/core/src/di/injector.ts
  2. +1 −1 packages/core/src/di/reflective_injector.ts
  3. +1 −1 packages/core/src/linker/component_factory_resolver.ts
@@ -59,7 +59,7 @@ export const INJECTOR_IMPL = INJECTOR_IMPL__PRE_R3__;
*/
export abstract class Injector {
static THROW_IF_NOT_FOUND = THROW_IF_NOT_FOUND;
static NULL: Injector = /* @__PURE__ */ new NullInjector();
static NULL: Injector = (/* @__PURE__ */ new NullInjector());

/**
* Retrieves an instance from the injector based on the provided token.
@@ -270,7 +270,7 @@ export abstract class ReflectiveInjector implements Injector {
}

export class ReflectiveInjector_ implements ReflectiveInjector {
private static INJECTOR_KEY = /* @__PURE__ */ ReflectiveKey.get(Injector);
private static INJECTOR_KEY = (/* @__PURE__ */ ReflectiveKey.get(Injector));
/** @internal */
_constructionCounter: number = 0;
/** @internal */
@@ -46,7 +46,7 @@ of the code in this cookbook
* @publicApi
*/
export abstract class ComponentFactoryResolver {
static NULL: ComponentFactoryResolver = /* @__PURE__ */ new _NullComponentFactoryResolver();
static NULL: ComponentFactoryResolver = (/* @__PURE__ */ new _NullComponentFactoryResolver());
/**
* Retrieves the factory object that creates a component of the given type.
* @param component The component type.

0 comments on commit ca510c8

Please sign in to comment.