MCPcopy Create free account
hub / github.com/angular/angular / compileDeclarationList

Function compileDeclarationList

packages/compiler/src/render3/view/compiler.ts:353–371  ·  view source on GitHub ↗

* Compiles the array literal of declarations into an expression according to the provided emit * mode.

(
  list: o.LiteralArrayExpr,
  mode: DeclarationListEmitMode,
)

Source from the content-addressed store, hash-verified

351 * mode.
352 */
353function compileDeclarationList(
354 list: o.LiteralArrayExpr,
355 mode: DeclarationListEmitMode,
356): o.Expression {
357 switch (mode) {
358 case DeclarationListEmitMode.Direct:
359 // directives: [MyDir],
360 return list;
361 case DeclarationListEmitMode.Closure:
362 // directives: function () { return [MyDir]; }
363 return o.arrowFn([], list);
364 case DeclarationListEmitMode.ClosureResolved:
365 // directives: function () { return [MyDir].map(ng.resolveForwardRef); }
366 const resolvedList = list.prop('map').callFn([o.importExpr(R3.resolveForwardRef)]);
367 return o.arrowFn([], resolvedList);
368 case DeclarationListEmitMode.RuntimeResolved:
369 throw new Error(`Unsupported with an array of pre-resolved dependencies`);
370 }
371}
372
373function stringAsType(str: string): o.Type {
374 return o.expressionType(o.literal(str));

Callers 1

Calls 1

propMethod · 0.45

Tested by

no test coverage detected