(type: Type<T>)
| 566 | * (either a NgModule or a standalone component / directive / pipe). |
| 567 | */ |
| 568 | export 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. |
no test coverage detected