Error on first run
eshcharc opened this issue · 15 comments
I configured typedoc.json
at the root of my lerna project.
It seemed to recognize all the project packages and locations, but failed on the following issue.
Log:
C:\{project_path}\node_modules\typedoc-plugin-lerna-packages\dist\plugin.js:58
const copyChildren = context.project.children.slice(0);
^TypeError: Cannot read property 'slice' of undefined
at LernaPackagesPlugin.onBeginResolve (C:\{project_path}\node_modules\typedoc-plugin-lerna-packages\dist\plugin.js:58:55)
at triggerEvents (C:\{project_path}\node_modules\typedoc\dist\lib\utils\events.js:128:43)
at triggerApi (C:\{project_path}\node_modules\typedoc\dist\lib\utils\events.js:110:13)
at eventsApi (C:\{project_path}\node_modules\typedoc\dist\lib\utils\events.js:21:18)
at Converter.trigger (C:\{project_path}\node_modules\typedoc\dist\lib\utils\events.js:264:13)
at Converter.resolve (C:\{project_path}\node_modules\typedoc\dist\lib\converter\converter.js:180:14)
at Converter.convert (C:\{project_path}\node_modules\typedoc\dist\lib\converter\converter.js:91:30)
at CliApplication.convert (C:\{project_path}\node_modules\typedoc\dist\lib\application.js:72:39)
at CliApplication.bootstrap (C:\{project_path}\node_modules\typedoc\dist\lib\cli.js:45:34)
at Object. (C:\{project_path}\node_modules\typedoc\bin\typedoc:5:5)
error Command failed with exit code 1.
B.T.W when I added typedoc.js
as explained in the README, it did not recognize the configuration, passed the build, but created no artifacts.
typedoc.json:
{
"name": "Project name",
"mode": "modules",
"out": "docs",
"readme": "README.md",
"exclude": [
"**/node_modules/**",
"**/*.spec.ts",
"**/tests/**/*.ts"
],
"excludePrivate": true
}
Does typedoc generate anything when you don't install this plugin? I wonder because context.project.children shouldnt be undefined.
Yes. Just tried, and a docs
folder was created with the main README.md
showing
Tried a clean typedoc
within one of the packages and it generated docs as well
Well, I couldn't make it work with either of the configuration files (typedoc 0.16.8
), but surprisingly, it did work when options were set from the CLI with flags.
Not my ideal solution, but at least it works.
Thank you for the feedback, and if you have any idea of why it happens, I'll be glad to hear.
Feel free to post a github repo I can use to reproduce. Maybe it's a windows issue.
I'm quite embarrassed to say, I ran it without mentioning the source files ('packages' folder).
Sorry for wasting your time. This issue can be closed now.
Thanks for your help anyways.
Similar error here with (typedoc 0.16.8
and typedoc-plugin-lerna-packages 0.3.0
):
- node: 12.13.0
- yarn: 1.15.2
Using TypeScript 3.7.5 from /monorepo/node_modules/typedoc/node_modules/typescript/lib
/monorepo/node_modules/typedoc/node_modules/typescript/lib/typescript.js:34103
if (symbol.flags & 33554432 /* Transient */)
^
TypeError: Cannot read property 'flags' of undefined
at getSymbolLinks (/monorepo/node_modules/typedoc/node_modules/typescript/lib/typescript.js:34103:24)
at getExportsOfModule (/monorepo/node_modules/typedoc/node_modules/typescript/lib/typescript.js:35607:25)
at Object.getExportsOfModuleAsArray [as getExportsOfModule] (/monorepo/node_modules/typedoc/node_modules/typescript/lib/typescript.js:35573:35)
at ExportDeclarationConverter.convert (/monorepo/node_modules/typedoc/dist/lib/converter/nodes/export.js:86:50)
at Converter.convertNode (/monorepo/node_modules/typedoc/dist/lib/converter/converter.js:116:53)
at /monorepo/node_modules/typedoc/dist/lib/converter/nodes/block.js:65:28
at Array.forEach (<anonymous>)
at BlockConverter.convertStatements (/monorepo/node_modules/typedoc/dist/lib/converter/nodes/block.js:64:24)
at /monorepo/node_modules/typedoc/dist/lib/converter/nodes/block.js:43:26
at Context.withScope (/monorepo/node_modules/typedoc/dist/lib/converter/context.js:101:9)
@eshcharc How did you fix it? I have the exact same problem.
I tried to call it with the CLI like this:
typedoc --out ./docs ./packages
Output:
Loaded plugin /path/to/node_modules/typedoc-plugin-lerna-packages
Using TypeScript 3.8.3 from /usr/local/lib/node_modules/typescript/lib
Lerna packages found {
'@testproject/testproject-core': 'packages/testproject-core',
'@testproject/testproject-core-ui': 'packages/testproject-core-ui',
'@testproject/testproject-content-data': 'packages/testproject-content-data',
'@testproject/testproject-content': 'packages/testproject-content',
'@testproject/testproject-commerce-data': 'packages/testproject-commerce-data',
'@testproject/testproject-commerce': 'packages/testproject-commerce',
'@testproject/create-testproject': 'packages/testproject-create',
'@testproject/testproject-pwa': 'packages/testproject-pwa'
}
/path/to/node_modules/typedoc-plugin-lerna-packages/dist/plugin.js:58
const copyChildren = context.project.children.slice(0);
^
TypeError: Cannot read property 'slice' of undefined
at LernaPackagesPlugin.onBeginResolve (/path/to/node_modules/typedoc-plugin-lerna-packages/dist/plugin.js:58:55)
at triggerEvents (/usr/local/lib/node_modules/typedoc/dist/lib/utils/events.js:128:43)
at triggerApi (/usr/local/lib/node_modules/typedoc/dist/lib/utils/events.js:110:13)
at eventsApi (/usr/local/lib/node_modules/typedoc/dist/lib/utils/events.js:21:18)
at Converter.trigger (/usr/local/lib/node_modules/typedoc/dist/lib/utils/events.js:264:13)
at Converter.resolve (/usr/local/lib/node_modules/typedoc/dist/lib/converter/converter.js:164:14)
at Converter.convert (/usr/local/lib/node_modules/typedoc/dist/lib/converter/converter.js:91:30)
at CliApplication.convert (/usr/local/lib/node_modules/typedoc/dist/lib/application.js:70:39)
at CliApplication.bootstrap (/usr/local/lib/node_modules/typedoc/dist/lib/cli.js:45:34)
at Object.<anonymous> (/usr/local/lib/node_modules/typedoc/bin/typedoc:5:5)
Nope. I thought it was okay, but now I see that it still exists. I tried to debug the plugin, but came up with nothing.
I left it in favor of other things, but I'll be happy if that is solved.
It seems that the plugin / typedoc doesn't like the wildcard sign (*) when mentioning lerna packages (e.g. in inputFiles option).
IMO, that's the cause for the slice of undefined
error. Workaround this is to explicitly name the packages of your project.
I've managed to enable it all (not before encountering the flags
error), and I might upload a sample project for you to examine later today.
I got it working with the exact versions from the readme and using npx typedoc
instead of npm run typedoc
(that was using the project version of typescript). Still seems this project needs an upgrade to be able to use typescript version 3.8.*
@marcj @eshcharc @dariusrosendahl
Actually, context.project.children
could be undefined in some cases. After I patched this line in my node_module
, it works.
typedoc: 0.17
typescript: 3.9
See: #23 (comment)