compodoc: [BUG] Error: Could not find the node's symbol.

Overview of the issue

After upgrading to compodoc 1.1.1 from 1.0.9 I got the reason: Error: Could not find the node's symbol. error

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

compodoc: 1.1.1 node: 9.8.0 mac: High Sierra

Angular configuration, a package.json file in the root folder

Angular: 5.2.9

Compodoc installed globally or locally ?

locally installed compodoc

Motivation for or Use Case

Cannot generate docs anymore

Reproduce the error

npm script: ./node_modules/.bin/compodoc -p src/tsconfig.app.json -d ./docs -t --theme stripe --disableCoverage --hideGenerator -n \"My Documentation\"

Related issues

1.0.9 compodoc version was working well

Suggest a Fix

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 40 (7 by maintainers)

Most upvoted comments

I am currently seeing this issue as well when routes are being analyzed. This is the initial output of the error:

[19:28:02] Analysing routes definitions and clean them if necessary
Unhandled Rejection at: Promise {
  <rejected> Error: Could not find the node's symbol.

I believe that this is happening due to our usage of a TS string enumeration to define the path of the individual routes. For example: (redacting portions of the config)

Enum file:

export enum SomeEnum {
    SOME_ROUTE = 'some-route'
}

Routing Module Config:

import { SomeEnum } from './some-enum.enum';

const routes: Routes = [
    {
        path: '',
        component: SomeParentComponent,
        children: [
                    {
                        path: SomeEnum.SOME_ROUTE,
                        loadChildren: '/path/to/module/to/load#SomeModule'
                    }
        ]
    }
];

Not ideal but I got this working by removing the Routes typing, example :

export coreRoutes : Routes = [ ... ]

Change to

export coreRoutes = [ ... ]

Same problem Compodoc version: 1.1.5 Typescript version : 2.9.1 Node.js version : v8.12.0 Operating system : Windows 10

We are using an enum in our route data in the following way:

{ path: 'somePath', component: someComponent, data: {someParaName: SomeEnum.SomeOption}}

this gives the Unhandled Rejection at: Promise error. It goes away when you remove the Routes typing as suggested by @WebStew above but then Compodoc just doesn’t generate the routes part of the documentation.

A fix for now is calling valueOf() on the enum:

{ path: 'somePath', component: someComponent, data: {someParaName: SomeEnum.SomeOption.valueOf()}}

The generation throws no errors and the routes are included in the documentation.

Some extra information. enum is imported as:

import { SomeEnum } from 'app/model';

Routes are declared as:

const APP_ROUTES: Routes = [
  { path: 'somePath', component: someComponent, data: {someParaName: SomeEnum.SomeOption.valueOf()}},
];



@vogloblinsky do you have any idea what is causing the error? Do you need more info/how can I help you pinpoint the issue?

Same here!

Some news?

I am getting this error with compodoc v1.1.2 if I make use of the “data” property on a route with a values that come from an import:

For example, this gives an error:

library.ts

import * as dataSelectors from './data.selectors';
export { dataSelectors }

app-routing.module.ts

import { dataSelectors } from './library'

const routes: Routes = [
  {
    path: '',
    component: MyContainerComponent,
    data: {selector: dataSelectors.getAllDataItems }
}]

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {}

But this does not give the error:

import { dataSelectors } from './library'

const mySelectors = {
  data: dataSelectors.getAllDataItems
};

const routes: Routes = [
  {
    path: '',
    component: MyContainerComponent,
    data: {selector: mySelectors.data }
}]

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {}

In my case it happens when route paths are imported from some const

import { ROUTES_MAP } from './config';

{
     path: ROUTES_MAP.products,
     component: ParentInfoComponent
 }

When I comment all the paths declarations - it works. It is also the same on 1.0.9 version

Ahh I need to remove the -t(silent) option from my script above almost forgot it 😃 The error appears after parsing my home-routing.module.ts lazy routes. Additional details is that I have main routes which are lazily loaded and one of them contains the following additional lazy loaded modules in home-routing.module.ts: image

Hope this helps @vogloblinsky

I solved this problem by using the solution @bartios posted earlier in this thread. When defining a Routes array in a routing module, reference enum values by their .valueOf() method.

So instead of: data: { fooProperty: FooEnum.FooPermission } Use: data: { fooProperty: FooEnum.FooPermission.valueof() }

Also having the same issue with version 1.1.8.

This is happening when i reference any route property from environment files e.g.

data: { title: environment.feature.name }

Having the same issue

Compodoc v1.1.7 Angular CLI 7.2.2

Clear up “Routes” types fixes the problem, but I think it’s not okay to do like that

Thanks @WebStew , would be great if @vogloblinsky can solve it in a nice manner. 😉

I had the same issue, and it was definitely my routing. Compodoc works if I change my routes from

const appRoutes: Routes =
  environment.app === "internal"
    ? [
        {
          path: "",
          component: HomeComponent
        },

        // otherwise redirect to home
        { path: "**", redirectTo: "" }
      ]
    : [
        {
          path: "",
          component: HomeComponent,
          canActivate: [AuthGuard, LicenseAgreementGuard]
        },
        { path: "welcome", component: WelcomeComponent },
        {
          path: "agreement",
          component: LicenseAgreementComponent,
          canActivate: [AuthGuard]
        },

        // otherwise redirect to home
        { path: "**", redirectTo: "" }
      ];

export const routing = RouterModule.forRoot(appRoutes);

to

const appRoutes: Routes = [{ path: "**", redirectTo: "" }];
export const routing = RouterModule.forRoot(appRoutes);

.

Let us know if you see what caused the issue @vogloblinsky in case of the nested lazy routes above.

Thanks in advance, meanwhile I reverted back to the 1.0.9 working version.

Online !

In one or two hours 😉

@shlomiassaf Thanks for the feedback. I will look that asap.

I can confirm this happens to me as well.

I have pinned the issue, but it’s trick to explain so i’ll do my best.

The issue might be external, coming from ts-simple-ast

For me it happens whenever I use a function call expression where the function is on an object, e.g. myObj.functionCall(). If the function is used directly (functionCall()) it works fine.

Example:

In file utils.ts I export the following:

export const utils = {
  doWork(): any {
     return {};
  }
}

now in my app.routes.ts:

import { Routes } from '@angular/router';

import { utils } from './utils';

export const ROUTES: Routes = [
  {
    path: '',
    children: [
      {
        'some-path',
        loadChildren: 'apps/lazy-app#LazyAppModule',
        data: utils.doWork()
      }
    ]
  }
];

The above code will result in the error.

To fix it we just need to use doWork() directly so we add:

const { doWork } = utils;

and then use it directly:

data: doWork()

Now no errors.

I believe this is coming from ts-simple-ast but i’m not sure.