question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Fails to generate documentation when using loadChildren in application routing module

See original GitHub issue
Overview of the issue

Compodoc fails to generate documentation after refactoring.

Operating System, Node.js, npm, compodoc version(s)

linux, node v8.16.0, compodoc 1.1.9

Angular configuration, a package.json file in the root folder
    "@angular/animations": "7.2.15",
    "@angular/cdk": "7.3.7",
    "@angular/common": "7.2.15",
    "@angular/compiler": "7.2.15",
    "@angular/core": "7.2.15",
    "@angular/elements": "7.2.15",
    "@angular/flex-layout": "7.0.0-beta.23",
    "@angular/forms": "7.2.15",
    "@angular/http": "7.2.15",
    "@angular/material": "7.3.7",
    "@angular/material-moment-adapter": "7.3.7",
    "@angular/platform-browser": "7.2.15",
    "@angular/platform-browser-dynamic": "7.2.15",
    "@angular/router": "7.2.15",
    "@ngrx/effects": "^7.4.0",
    "@ngrx/router-store": "^7.4.0",
    "@ngrx/store": "^7.4.0",
    "@ngrx/store-devtools": "^7.4.0",
    "@ngx-translate/core": "11.0.1",
    "@webcomponents/custom-elements": "1.2.4",
    "@webcomponents/webcomponentsjs": "2.2.10",
    "apollo-angular": "1.5.0",
    "apollo-angular-link-http": "1.6.0",
    "apollo-cache-inmemory": "1.6.0",
    "apollo-client": "2.6.0",
    "apollo-link": "1.2.11",
    "apollo-link-error": "1.1.10",
    "apollo-upload-client": "10.0.1",
    "apollo-utilities": "1.3.0",
    "core-js": "2.6.5",
    "hammerjs": "2.0.8",
    "material-design-icon-fonts": "3.0.1",
    "moment": "2.24.0",
    "ngx-take-until-destroy": "5.4.0",
    "roboto-fontface": "0.10.0",
    "rxjs": "6.5.2",
    "zone.js": "0.9.1"
    "@angular-devkit/build-angular": "0.13.9",
    "@angular/cli": "7.3.9",
    "@angular/compiler-cli": "7.2.15",
    "@angular/language-service": "7.2.15",
    "@ngrx/schematics": "^7.4.0",
    "@types/graphql": "14.2.0",
    "@types/jasmine": "3.3.12",
    "@types/jasminewd2": "2.0.6",
    "@types/node": "12.0.2",
    "angular-file": "1.2.2",
    "ngrx-store-logger": "^0.2.3",
    "typescript": "3.2.4"
Compodoc installed globally or locally ?

globally

If possible sourcecode of the file where it breaks

The following routes config generates error:

export const ROUTES: Routes = [
  {
    path: '',
    canActivate: [ AnonymousGuard ],
    children: [
      {
        path: '',
        component: WidgetComponent,
        data: {
          title: `${environment.appName} widget`,
          color: 'primary',
          activatedMode: 'login',
          restrictMode: 'index',
          displayConfig: false
        } as WidgetComponentData
      }
    ]
  }
];
If possible your terminal logs before the error

First lod entry:

[09:41:43] Analysing routes definitions and clean them if necessary
[09:41:43] Routes parsing error, maybe a trailing comma or an external variable, trying to fix that later after sources scanning.

Actual error:

[10:36:10] Analysing routes definitions and clean them if necessary
Unhandled Rejection at: Promise {
  <rejected> Error: Could not find the node's symbol.
    at InvalidOperationError.BaseError [as constructor] (/usr/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/BaseError.js:7:28)
    at new InvalidOperationError (/usr/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/InvalidOperationError.js:8:28)
    at Object.throwIfNullOrUndefined (/usr/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/helpers.js:96:15)
    at Identifier.Node.getSymbolOrThrow (/usr/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/compiler/common/Node.js:131:23)
    at RouterParserUtil.cleanFileDynamics (/usr/lib/node_modules/@compodoc/compodoc/dist/index-cli.js:4923:18)
    at AngularDependencies.getSourceFileDecorators (/usr/lib/node_modules/@compodoc/compodoc/dist/index-cli.js:7410:46)
    at /usr/lib/node_modules/@compodoc/compodoc/dist/index-cli.js:7218:31
    at Array.map (<anonymous>)
    at AngularDependencies.getDependencies (/usr/lib/node_modules/@compodoc/compodoc/dist/index-cli.js:7207:21)
    at CliApplication.Application.getDependenciesData (/usr/lib/node_modules/@compodoc/compodoc/dist/index-cli.js:8757:40) } reason: Error: Could not find the node's symbol.
    at InvalidOperationError.BaseError [as constructor] (/usr/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/BaseError.js:7:28)
    at new InvalidOperationError (/usr/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/InvalidOperationError.js:8:28)
    at Object.throwIfNullOrUndefined (/usr/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/errors/helpers.js:96:15)
    at Identifier.Node.getSymbolOrThrow (/usr/lib/node_modules/@compodoc/compodoc/node_modules/ts-simple-ast/dist/compiler/common/Node.js:131:23)
    at RouterParserUtil.cleanFileDynamics (/usr/lib/node_modules/@compodoc/compodoc/dist/index-cli.js:4923:18)
    at AngularDependencies.getSourceFileDecorators (/usr/lib/node_modules/@compodoc/compodoc/dist/index-cli.js:7410:46)
    at /usr/lib/node_modules/@compodoc/compodoc/dist/index-cli.js:7218:31
    at Array.map (<anonymous>)
    at AngularDependencies.getDependencies (/usr/lib/node_modules/@compodoc/compodoc/dist/index-cli.js:7207:21)
    at CliApplication.Application.getDependenciesData (/usr/lib/node_modules/@compodoc/compodoc/dist/index-cli.js:8757:40)
[10:36:16] Sorry, but there was a problem during parsing or generation of the documentation. Please fill an issue on github. (https://github.com/compodoc/compodoc/issues/new)
Motivation for or Use Case

updated routing

Reproduce the error

try using routing configuration in code example

Related issues

bugs with similar console output were reported

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:7

github_iconTop GitHub Comments

1reaction
bop10commented, Aug 28, 2019

Routes is the same than Route[] (is a type: export declare type Routes = Route[];).

Compodoc should work with the both of them, but thank you for the workaround. 👍

1reaction
rfprodcommented, Jun 21, 2019

Well, eventually got it fixed by using Route[] instead of Routes in child routing modules, and old scheme for loading children stopped producing bugs.

Child routing that does not produce bug is like

export const CHILD_ROUTES: Route[] = [
  {
    path: '',
    canActivate: [ AnonymousGuard ],
    children: [
      {
        path: '',
        component: WidgetComponent,
        data: {
          title: `${environment.appName} widget`,
          color: 'primary',
          activatedMode: 'login',
          restrictMode: 'index',
          displayConfig: false
        } as WidgetComponentData
      }
    ]
  }
];

and it is loaded like (assuming child module is called ChildModule)

loadChildren: () => ChildModule
Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 11 - 'Cannot match any routes' using children routing
I have a multi-module Angular 11 project and I am trying to implement routing. Based on the documentation, I did this: app-routing.module.ts
Read more >
Common Routing Tasks - Angular
The following command uses the Angular CLI to generate a basic Angular application with an application routing module, called AppRoutingModule , which is...
Read more >
Resolving errors faced while implementing Lazy Loading with ...
It is a known bug in Angular that lazy loading module does not work well with Auxiliary routes / named router. For a...
Read more >
Working with Angular 14 Router - Techiediaries
In this tutorial part, we'll learn about Angular Router by example and will teach you everything you need to start using Angular routing...
Read more >
Manually Lazy Load Modules And Components In Angular
Based on this configuration data, multiple modules and/or components need to be lazy-loaded and its routes dynamically added to the application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found