(type: Type<T>)
| 551 | * (either a NgModule or a standalone component / directive / pipe). |
| 552 | */ |
| 553 | export function transitiveScopesFor<T>(type: Type<T>): NgModuleTransitiveScopes { |
| 554 | if (isNgModule(type)) { |
| 555 | const scope = depsTracker.getNgModuleScope(type); |
| 556 | const def = getNgModuleDefOrThrow(type); |
| 557 | return { |
| 558 | schemas: def.schemas || null, |
| 559 | ...scope, |
| 560 | }; |
| 561 | } else if (isStandalone(type)) { |
| 562 | const directiveDef = getComponentDef(type) || getDirectiveDef(type); |
| 563 | if (directiveDef !== null) { |
| 564 | return { |
| 565 | schemas: null, |
| 566 | compilation: { |
| 567 | directives: new Set<any>(), |
| 568 | pipes: new Set<any>(), |
| 569 | }, |
| 570 | exported: { |
| 571 | directives: new Set<any>([type]), |
| 572 | pipes: new Set<any>(), |
| 573 | }, |
| 574 | }; |
| 575 | } |
| 576 | |
| 577 | const pipeDef = getPipeDef(type); |
| 578 | if (pipeDef !== 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>(), |
| 587 | pipes: new Set<any>([type]), |
| 588 | }, |
| 589 | }; |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | // TODO: change the error message to be more user-facing and take standalone into account |
| 594 | throw new Error(`${type.name} does not have a module def (ɵmod property)`); |
| 595 | } |
| 596 | |
| 597 | /** |
| 598 | * Compute the pair of transitive scopes (compilation scope and exported scope) for a given module. |
no test coverage detected
searching dependent graphs…