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

Function transitiveScopesFor

packages/core/src/render3/jit/module.ts:568–610  ·  view source on GitHub ↗
(type: Type<T>)

Source from the content-addressed store, hash-verified

566 * (either a NgModule or a standalone component / directive / pipe).
567 */
568export function transitiveScopesFor<T>(type: Type<T>): NgModuleTransitiveScopes {
569 if (isNgModule(type)) {
570 const scope = depsTracker.getNgModuleScope(type);
571 const def = getNgModuleDefOrThrow(type);
572 return {
573 schemas: def.schemas || null,
574 ...scope,
575 };
576 } else if (isStandalone(type)) {
577 const directiveDef = getComponentDef(type) || getDirectiveDef(type);
578 if (directiveDef !== null) {
579 return {
580 schemas: null,
581 compilation: {
582 directives: new Set<any>(),
583 pipes: new Set<any>(),
584 },
585 exported: {
586 directives: new Set<any>([type]),
587 pipes: new Set<any>(),
588 },
589 };
590 }
591
592 const pipeDef = getPipeDef(type);
593 if (pipeDef !== null) {
594 return {
595 schemas: null,
596 compilation: {
597 directives: new Set<any>(),
598 pipes: new Set<any>(),
599 },
600 exported: {
601 directives: new Set<any>(),
602 pipes: new Set<any>([type]),
603 },
604 };
605 }
606 }
607
608 // TODO: change the error message to be more user-facing and take standalone into account
609 throw new Error(`${type.name} does not have a module def (ɵmod property)`);
610}
611
612/**
613 * Compute the pair of transitive scopes (compilation scope and exported scope) for a given module.

Callers 4

compileComponentFunction · 0.90
getScopeOfModuleMethod · 0.85

Calls 7

isNgModuleFunction · 0.90
getNgModuleDefOrThrowFunction · 0.90
isStandaloneFunction · 0.90
getComponentDefFunction · 0.90
getDirectiveDefFunction · 0.90
getPipeDefFunction · 0.90
getNgModuleScopeMethod · 0.65

Tested by

no test coverage detected