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

Method typeCtorFor

packages/compiler/test/typecheck/util.ts:267–297  ·  view source on GitHub ↗
(dir: TcbDirectiveMetadata)

Source from the content-addressed store, hash-verified

265 }
266
267 typeCtorFor(dir: TcbDirectiveMetadata): TcbExpr {
268 const existing = this.typeCtors.get(dir.ref.key);
269 if (existing !== undefined) {
270 return new TcbExpr(existing);
271 }
272
273 if (dir.requiresInlineTypeCtor) {
274 // The type constructor is declared inline in the directive class.
275 const expr = `${this.referenceTcbValue(dir.ref).print()}.ngTypeCtor`;
276 this.typeCtors.set(dir.ref.key, expr);
277 return new TcbExpr(expr);
278 }
279
280 const fnName = `_ctor${this.nextTypeCtorId++}`;
281 const meta: TypeCtorMetadata = {
282 fnName,
283 body: true,
284 fields: {inputs: dir.inputs},
285 coercedInputFields: dir.coercedInputFields,
286 };
287 this.typeCtorStatements.push(
288 generateTypeCtorDeclaration(
289 this,
290 meta,
291 this.referenceTcbValue(dir.ref),
292 dir.typeParameters ?? undefined,
293 ),
294 );
295 this.typeCtors.set(dir.ref.key, fnName);
296 return new TcbExpr(fnName);
297 }
298
299 pipeInst(pipe: TcbPipeMetadata): TcbExpr {
300 const existing = this.pipeInsts.get(pipe.ref.key);

Callers

nothing calls this directly

Calls 6

referenceTcbValueMethod · 0.95
getMethod · 0.65
setMethod · 0.65
printMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected