[BUG] "TypeError: Cannot read property 'text' of undefined" with generating documentation with routes graph
See original GitHub issueOverview of the issue
Documentation generation failing with error like below during documentation generation on routing module file when there are too many (?) thing exported from file with the routing module.
[10:33:56] Analysing routes definitions and clean them if necessary Unhandled Rejection at: Promise { <rejected> TypeError: Cannot read property 'text' of undefined at E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:1397:55 at Function.ArrayUtils.find (E:\Projects\someFolder\rwd\node_modules\ts-simple-ast\dist\utils\ArrayUtils.js:37:21) at Object.getNodeByNameOrFindFunction (E:\Projects\someFolder\rwd\node_modules\ts-simple-ast\dist\utils\compiler\getNodeByNameOrFindFunction.js:10:36) at SourceFile.StatementedNode.class_1.getVariableDeclaration (E:\Projects\someFolder\rwd\node_modules\ts-simple-ast\dist\compiler\statement\StatementedNode.js:312:28) at RouterParserUtil.cleanCallExpressions (E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:1394:45) at Dependencies.getSourceFileDecorators (E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:5811:45) at E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:5638:27 at Array.map (<anonymous>) at Dependencies.getDependencies (E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:5632:21) at CliApplication.Application.getDependenciesData (E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:7309:40) } reason: TypeError: Cannot read property 'text' of undefined at E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:1397:55 at Function.ArrayUtils.find (E:\Projects\someFolder\rwd\node_modules\ts-simple-ast\dist\utils\ArrayUtils.js:37:21) at Object.getNodeByNameOrFindFunction (E:\Projects\someFolder\rwd\node_modules\ts-simple-ast\dist\utils\compiler\getNodeByNameOrFindFunction.js:10:36) at SourceFile.StatementedNode.class_1.getVariableDeclaration (E:\Projects\someFolder\rwd\node_modules\ts-simple-ast\dist\compiler\statement\StatementedNode.js:312:28) at RouterParserUtil.cleanCallExpressions (E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:1394:45) at Dependencies.getSourceFileDecorators (E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:5811:45) at E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:5638:27 at Array.map (<anonymous>) at Dependencies.getDependencies (E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:5632:21) at CliApplication.Application.getDependenciesData (E:\Projects\someFolder\rwd\node_modules\@compodoc\compodoc\dist\index-cli.js:7309:40)
File on which generation works:
import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { ErrorPageComponent } from "./error-page.component";
export const errorRoutes: Routes = [
{
path: "error",
component: ErrorPageComponent
}
];
@NgModule({
imports: [
RouterModule.forChild(errorRoutes)
]
})
export class ErrorRoutingModule {
}
File on which generation fails:
import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { ErrorPageComponent } from "./error-page.component";
export const SOMETHING: string = "aaa";
export const errorRoutes: Routes = [
{
path: "error",
component: ErrorPageComponent
}
];
@NgModule({
imports: [
RouterModule.forChild(errorRoutes)
]
})
export class ErrorRoutingModule {
}
Operating System, Node.js, npm, compodoc version(s)
- Windows 8.1
- NodeJs - 8.10.0
- npm 5.7.1
- compodoc 1.1.3
Angular configuration, a package.json
file in the root folder
As we have quite complex tree-structured projects isn’t is actual content, but most important parts of merged configurations:
{
"author": "XXX",
"name": "xxx",
"version": "0.0.1",
"dependencies": {
"@angular/animations": "5.2.*",
"@angular/common": "5.2.*",
"@angular/compiler": "5.2.*",
"@angular/core": "5.2.*",
"@angular/forms": "5.2.*",
"@angular/http": "5.2.*",
"@angular/platform-browser": "5.2.*",
"@angular/platform-browser-dynamic": "5.2.*",
"@angular/router": "5.2.*",
"@ngrx/effects": "5.0.*",
"@ngrx/router-store": "5.0.*",
"@ngrx/store": "5.0.*",
"@ngx-translate/core": "9.1.*",
"core-js": "2.5.*",
"lodash": "4.17.*",
"moment": "2.20.*",
"ng2-markdown-to-html": "1.3.*",
"ng2-nouislider": "1.7.*",
"ngrx-store-localstorage": "5.0.*",
"normalize.css": "7.0.*",
"primeng": "5.2.*",
"prismjs": "1.14.*",
"rxjs": "5.5.*",
"zone.js": "0.8.*"
},
"devDependencies": {
"@angular/compiler-cli": "5.2.*",
"@angular/language-service": "5.2.*",
"@compodoc/compodoc": "1.1.*",
"@ngrx/store-devtools": "4.1.*",
"@ngtools/webpack": "1.10.*",
"@types/file-saver": "^1.3.0",
"@types/jasmine": "2.8.*",
"@types/jasmine-expect": "3.6.*",
"@types/jasminewd2": "2.0.*",
"@types/karma": "1.7.*",
"@types/lodash": "4.14.104",
"@types/node": "6.*.*",
"@types/run-sequence": "0.0.*",
"@types/webpack": "3.8.*",
"@types/webpack-env": "1.13.*",
"angular2-template-loader": "0.6.*",
"awesome-typescript-loader": "3.4.*",
"codecov": "3.0.*",
"codelyzer": "4.3.*",
"compare-json": "0.3.*",
"concurrently": "3.5.*",
"copy": "0.3.2",
"copy-webpack-plugin": "4.1.*",
"css-loader": "0.28.*",
"css-hot-loader": "1.3.*",
"extract-text-webpack-plugin": "3.0.*",
"file-loader": "1.1.*",
"html-webpack-plugin": "3.0.*",
"istanbul-instrumenter-loader": "3.0.*",
"jasmine-core": "2.8.*",
"jasmine-marbles": "0.2.*",
"jasmine-spec-reporter": "4.2.*",
"json-loader": "0.5.*",
"karma": "2.0.*",
"karma-chrome-launcher": "2.2.*",
"karma-cli": "1.0.*",
"karma-coverage-istanbul-reporter": "1.4.*",
"karma-firefox-launcher": "1.0.*",
"karma-jasmine": "1.1.*",
"karma-jasmine-html-reporter": "0.2.*",
"karma-jasmine-matchers": "3.7.*",
"karma-junit-reporter": "1.2.*",
"karma-mocha-reporter": "2.2.*",
"karma-phantomjs-launcher": "1.0.*",
"karma-remap-coverage": "0.1.*",
"karma-sourcemap-loader": "0.3.*",
"karma-webpack": "2.0.*",
"lite-server": "2.3.*",
"ngrx-store-freeze": "0.2.*",
"node-sass": "4.7.*",
"phantomjs-prebuilt": "2.1.*",
"postcss": "6.0.*",
"postcss-loader": "2.1.*",
"protractor": "5.3.*",
"raw-loader": "0.5.*",
"run-sequence": "2.2.*",
"sass-loader": "6.0.*",
"source-map-explorer": "1.5.*",
"source-map-loader": "0.2.*",
"to-string-loader": "1.1.*",
"tslint": "5.10.*",
"tslint-consistent-codestyle": "1.13.*",
"tslint-language-service": "0.9.*",
"typescript": "2.5.*",
"uglifyjs-webpack-plugin": "1.1.*",
"webpack": "3.11.*",
"webpack-dev-server": "2.11.*",
"webpack-node-externals": "1.6.*"
},
"engines": {
"node": ">=6.9.0 <9.0.0",
"npm": ">=3.10.3 <6.0.0"
}
}
Compodoc installed globally or locally ?
Locally
Motivation for or Use Case
Can’t create a documentation with routing graph.
Reproduce the error
Sample files presented in first part of the bug report.
Related issues
Maybe #427
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7
Top GitHub Comments
@nixallover, was scratching my head on this one until coming across your solution. Perfect!
I was reading in some environment settings for
useHash
andenableTracing
. Errors out when using aconst
, but works fine when returning from a function.Fail 👎
Pass 👍
@mkp05 Thanks so much for posting this! You helped me find a solution for my project. I had a const that held some shared static text that was being passed into some of my routes as title data. I fixed the issue by changing that const string to a function that returns a string.
Before (produces error):
After (error-free):