Angular Modernizer
    Preparing search index...

    Finds the dynamic creation sites of a component.

    Answers "who creates this component outside a template, with which data, and where does the result go?": every call or new that hands the component class to a parameter typed as a component constructor (Type<T>, ComponentType<T>), e.g. dialog.open(XComponent, config), new ComponentPortal(XComponent), vcr.createComponent(XComponent) or a project wrapper such as appDialog.open(XComponent, action, data).

    No list of known APIs: a creation site is recognised by the resolved parameter type (a constructor type, bundled aliases like Type$1<C> included). Project wrappers are followed through their parameter or the field it is stored in down to the library call (via). Starting from the references of the component class, the value is followed through variables, fields, DI tokens ({ provide: T, useValue: X } read with inject(T) / @Inject(T)), method returns (also through interfaces), .then callbacks and destructured lazy imports; string literals equal to the component's selector count when the call returns a component type (selector registries). Test files are skipped unless includeTestHosts. The project is only read.

    Routes: an object literal property whose contextual type is a component constructor (component: X) or a function yielding one (loadComponent: () => import('./x').then(m => m.X)) is a site too; Route entries carry their path, guards, data and resolve.

    Registries: a class listed in an array held by a field or variable (dynamicComponents = [X, Y], also overriding an abstract base member) follows the reads of that array (arr[i], for...of, find) out of the lookup method. Where the value leaves a method call with a string argument, the argument decides: its literal values (traceStringLiterals) include the component's selector: certain; exclude it completely: not a host; otherwise the site is a candidate with the selector expression, unless an equality guard around the site (if (sel === 'app-x'), case 'app-x':) fixes the selector.

    The result of a site is followed further by DynamicResultFollower.

    const sites = new DynamicHostFinder(project).find(confirmDialogClass, 'app-confirm-dialog');
    // sites[0].host -> { component: 'ListComponent', sink: 'AppDialog.open',
    // via: ['MatDialog.open'], resolution: ['literal'], result: { use: 'chained', chain: ['subscribe'] } }
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Creation sites of component, sorted by file and line.

      Parameters

      • component: ClassDeclaration
      • Optionalselector: string

        The component's selector; comma-separated parts are matched one by one against string literals.

      Returns DynamicSite[]