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

Function compileDeclarationList

packages/compiler/src/render3/view/compiler.ts:348–366  ·  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

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

Callers 1

Calls 1

propMethod · 0.45

Tested by

no test coverage detected