Skip to content

Commit 5504ca1

Browse files
authored
feat(compiler): Added support for limited function calls in metadata. (angular#9125)
The collector now collects the body of functions that return an expression as a symbolic 'function'. The static reflector supports expanding these functions statically to allow provider macros. Also added support for the array spread operator in both the collector and the static reflector.
1 parent 5c0cfde commit 5504ca1

File tree

10 files changed

+638
-138
lines changed

10 files changed

+638
-138
lines changed

modules/@angular/compiler-cli/integrationtest/src/features.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as common from '@angular/common';
22
import {Component, Inject, OpaqueToken} from '@angular/core';
33

4+
import {wrapInArray} from './funcs';
5+
46
export const SOME_OPAQUE_TOKEN = new OpaqueToken('opaqueToken');
57

68
@Component({
@@ -23,7 +25,7 @@ export class CompWithProviders {
2325
<input #a>{{a.value}}
2426
<div *ngIf="true">{{a.value}}</div>
2527
`,
26-
directives: [common.NgIf]
28+
directives: [wrapInArray(common.NgIf)]
2729
})
2830
export class CompWithReferences {
2931
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function wrapInArray(value: any): any[] {
2+
return [value];
3+
}

modules/@angular/compiler-cli/src/reflector_host.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class ReflectorHost implements StaticReflectorHost, ImportGenerator {
2929
coreDecorators: '@angular/core/src/metadata',
3030
diDecorators: '@angular/core/src/di/decorators',
3131
diMetadata: '@angular/core/src/di/metadata',
32+
diOpaqueToken: '@angular/core/src/di/opaque_token',
3233
animationMetadata: '@angular/core/src/animation/metadata',
3334
provider: '@angular/core/src/di/provider'
3435
};

0 commit comments

Comments
 (0)