Documentation

Angular routes

ADR 0036 (with Revision 1, review 1); aggregate extractors-49 (router payload version 2). Routing facts are linked on every run in internal/extract/angular from the router payload (router syntax, ADR 0035), declaration constants and mutations, captured class decorators, InjectionSyntax.TypeImports and the ADR 0031 roles, standalone values and ordered NgModule imports and exports. Contract v1 is unchanged; existing records are untouched.

Proof

Registrations and roots

Route lists

Array literals are read in order: object elements are routes; spreads of an array literal or of a proven unmutated module const array are flattened (cycle guarded); other elements raise info angular_route_entry_unresolved. An identifier or member chain resolves to a DeclarationSyntax.Constants entry or a router Arrays entry of the target file (an export default [...] array is default). Parentheses, as and satisfies are transparent. Objects inside a call's first argument use that call's Scope and Shadows; all others use module scope with no shadows. children nests a list.

An object with a spread, computed key, method or accessor is partial and R6 is skipped. A method or accessor whose name the router payload records (methods) defines only that key: present but never evaluated. A spread, computed key or unnamed method makes the object open: keys before it are unknown, and absent keys are unknown, not absent (A3). An open object composes no path; a partial object with only named methods composes when its path is a known own key and outlet and matcher are absent or known. Duplicate keys: the last wins.

Routes whose R6 codes include children_with_load_children, redirect_with_load_children or redirect_with_children are never traversed: Angular rejects them, so neither children nor loadChildren contribute nodes, paths or loads_children edges through them (their own node and warning stay).

Loaders and targets

A loadComponent/loadChildren pair matches the router loader of the same file whose ValueSpan equals the pair value span. import_default resolves the module's default export, import_member its Member, sync the cached value with the loader's Scope and Shadows; inadmissible loaders are unresolved with the cached reason.

Nodes

Kind ui_route, level 4, file and span of the object literal, content hash of the normalized source over that span (computed at link time). Names come from source literals only; see identities.

Attributes (flat): framework: "angular"; path (evaluated string or null; omitted when absent, null on open objects without one); matcher: true; paths (sorted {path, scope?}); lazy (true when loadComponent is an own known key or a named method, false when absent, null when it may be overwritten or supplied by a spread); component and children_load ({status, target?, reason?}, status linked, external, unresolved or invalid); redirect_to, path_match, outlet (string or null; a v21 redirect function is a target object); title (string or target object); guards (present keys of can_activate, can_match, can_activate_child, can_deactivate, can_load, each a source-ordered list of target objects, or null when the value is not an array literal); resolve (key to target object, or null); providers: true; partial: true; invalid (sorted R6 codes); scope: "test" for test-file objects. On open objects every absent key that a spread could supply is unknown: matcher, redirect_to, path_match, outlet, title, resolve and providers are null, each absent guard key is null, and component / children_load are {status: "unresolved", reason: "may be supplied by a spread or computed key"}. Named methods give component / children_load status unresolved ("value is a method or accessor; not evaluated") and null for other keys. Attribute strings never contain U+0000-U+001F (such values are unknown).

Paths

Start from the chain prefix, append each path ('' adds nothing), join with "/", ensure a leading slash, collapse repeated slashes and drop a trailing slash except for the root; case, :params and ** are kept. Composition stops for a route and its descendants when the path is unknown, a matcher is present, the path starts with "/", the outlet is not primary ('' and 'primary' are primary) or unknown, or an ancestor stopped. A chain is test-scope if the root call or bootstrap, a registration, a loading route or the object itself is in a test file; entries merge by path and a production chain omits scope.

Edges

All facts with confidence 1. routes_to: ui_route to linked component class, evidence the component or loader value span. loads_children: ui_route to the lazy NgModule class or the loaded array's variable/file node, evidence the loader value span. contains: owner (or file) to each top-level route and parent route to each child, evidence the contained route's file and span (the HTTP route convention).

Validation (R6)

validateNode is evaluated with Angular truthiness, only for non-partial objects and only when a violation is certain. Codes: named_outlet_without_target, redirect_with_children, redirect_with_load_children, children_with_load_children, component_with_load_component, redirect_with_component, redirect_with_guard (canActivate; canMatch only for proven Angular majors of 21 or later), path_with_matcher, missing_target, missing_path, leading_slash, empty_path_redirect_without_path_match. Each raises a warning angular_route_invalid.

Diagnostics

Code Severity When
angular_route_invalid warning an R6 violation
angular_route_target_invalid warning a proven component or loader target of the wrong kind
angular_route_for_root_lazy warning forRoot reached through a lazy closure
angular_route_root_unproven info a registration not reached from a proven root
angular_route_entry_unresolved info an unresolved route list or entry
angular_route_cycle info a lazy chain revisits a module or array

Messages name the file, line and 1-based column of the object or call (route at <file>:<line>:<column>: <reason>) and the reason.

Not modeled: provideRoutes, raw ROUTES providers, resetConfig, importProvidersFrom (including RouterModule.forRoot inside it, which emits nothing), route-level providers, routerLink, guard and resolver edges, provider order, mutations through calls such as Object.assign(routes[0], ...) or Object.assign(cfg, {providers: []}) (ADR 0031 gap), and writes through wrapped receivers such as (ROUTES as any[]).length = 0 (ADR 0036 known gaps). The fixture is testdata/fixtures/angular-routes.

Report a problem with this pageSource: docs/extract/angular-routes.md