MCPcopy Index your code
hub / github.com/angular/angular / getAOTCompiledComponent

Function getAOTCompiledComponent

packages/core/test/test_bed_spec.ts:1681–1736  ·  view source on GitHub ↗
(
      selector: string,
      dependencies: Array<Type<unknown>> = [],
      deferrableDependencies: Array<Type<unknown>> = [],
    )

Source from the content-addressed store, hash-verified

1679 * outside of TestBed) for cases when defer blocks are used.
1680 */
1681 const getAOTCompiledComponent = (
1682 selector: string,
1683 dependencies: Array<Type<unknown>> = [],
1684 deferrableDependencies: Array<Type<unknown>> = [],
1685 ) => {
1686 class ComponentClass {
1687 static ɵfac = () => new ComponentClass();
1688 static ɵcmp = defineComponent({
1689 type: ComponentClass,
1690 selectors: [[selector]],
1691 decls: 2,
1692 vars: 0,
1693 dependencies,
1694 consts: [['dir']],
1695 template: (rf: any, ctx: any) => {
1696 if (rf & 1) {
1697 elementStart(0, 'div', 0);
1698 text(1, `${selector} cmp!`);
1699 elementEnd();
1700 }
1701 },
1702 });
1703 }
1704 if (dependencies.length || deferrableDependencies.length) {
1705 setClassMetadataAsync(
1706 ComponentClass,
1707 function () {
1708 const promises: Array<Promise<Type<unknown>>> = deferrableDependencies.map(
1709 // Emulates a dynamic import, e.g. `import('./cmp-a').then(m => m.CmpA)`
1710 (dep) => new Promise((resolve) => setTimeout(() => resolve(dep))),
1711 );
1712 return promises;
1713 },
1714 function (...deferrableSymbols) {
1715 setClassMetadata(
1716 ComponentClass,
1717 [
1718 {
1719 type: Component,
1720 args: [
1721 {
1722 selector,
1723 imports: [...dependencies, ...deferrableSymbols],
1724 template: `<div>root cmp!</div>`,
1725 },
1726 ],
1727 },
1728 ],
1729 null,
1730 null,
1731 );
1732 },
1733 );
1734 }
1735 return ComponentClass;
1736 };
1737
1738 it('should not require compilerComponents if the component with a defer-block is not overridden', async () => {

Callers 1

test_bed_spec.tsFile · 0.85

Calls 5

setClassMetadataAsyncFunction · 0.90
setTimeoutFunction · 0.85
setClassMetadataFunction · 0.85
mapMethod · 0.80
resolveFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…