typedoc: TypeError: Cannot read property 'flags' of undefined
I got this error during the execution of typedoc:
return !!(type.flags & 80896);
^
TypeError: Cannot read property 'flags' of undefined
at ReferenceConverter.supportsNode ([....]node_modules\typedoc\lib\converter\types\reference.js:26:23)
at Converter.convertType ([....]node_modules\typedoc\lib\converter\converter.js:127:31)
at [....]node_modules\typedoc\lib\converter\nodes\class.js:47:63
at Context.withScope ([....]node_modules\typedoc\lib\converter\context.js:99:9)
at ClassConverter.convert ([....]node_modules\typedoc\lib\converter\nodes\class.js:35:17)
at Converter.convertNode ([....]node_modules\typedoc\lib\converter\converter.js:117:53)
at [....]node_modules\typedoc\lib\converter\nodes\block.js:71:33
at Array.forEach (native)
at BlockConverter.convertStatements ([....]node_modules\typedoc\lib\converter\nodes\block.js:69:29)
at [....]node_modules\typedoc\lib\converter\nodes\block.js:55:27
Does someone has an idea what the problem could be?
Typedoc v. 0.4.1 Tpyescript v.1.18.10
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 8
- Comments: 26
Have the same issue (node v6.9.1)
I ran into this issue when I wasn’t compiling something outside of my source directory. My tsconfig had
files [‘all.ts’ (from ./src), ‘…/typings/index.d.ts’]
but I was only running
typedoc --out ./doc ./src
The solution was to run
typedoc --out ./doc ./src ./typings/index.d.ts
The root cause is that it’s a configuration issue, but it’s a code issue in that the error thrown is unhelpful.
I’m using TypeScript 2.0.6 and am getting this error.
--excludeExternals
did not resolve the issue.Experienced the same issue,
--excludeExternals
didn’t work for me.We had to use
--moduleResolution node
Edit: Using TypeScript 1.8.10
I was having the same issue, while using the typedoc api to generate the docs. Firstly, I overrode the
supportsNode
functions to stop theCannot read property 'flags' of undefined
error (thanks @mashaalmemon for the idea):Note that those are the only two type converters that attempt to access
type.flags
, so this should cover all cases.After that, the undefined error went away, but I got a lot of module errors. This was because my code required
moduleResolution
to be classic, but hadn’t configured that in my typedoc code. I enabled this using the code:After that, typedoc ran successfully. I could also then remove the hack above, and it would still succeed.
This seems to indicate the
Cannot read property 'flags' of undefined
error is hiding other more appropriate errors, making the initial hack fix possibly a good idea. Also, it appears to be cause by multiple config errors (e.g. it had nothing to do withexcludeExternals
for me while that fixed the problem for other people).Here is the full code I’m using to generate my docs:
@aciccarello Was working on a PR and realized that after some changes in my typedoc setup that I was no longer able to replicate the error condition. The current 0.4.4 release was working. Digging deeper, realized that this may be simply a configuration problem and not a code problem.
I was experiencing this error when typedoc was trying to document “external” libraries (libraries external to my project as I understand it). Thus the issue may have been related to referenced typescript and not your own.
Whoever is experiencing this, try to set the “–excludeExternals” flag:
typedoc --excludeExternals
OR if using “gulp-typedoc” like me, set “excludeExternals:true”:
Thus no PR may be necessary for this issue. Can some of the folks in here try this and advise? @samvv @kylenicola @ajayambre
If so, maybe “excludeExternals” should be set to “true” as a default. I don’t see why external libraries should be documented by default?
@aciccarello My work around was a bit “hacky” and satisfied my need. Ultimately a variable that is expected to be set is not yet set when encountered, and so typedoc fails.
I’ll aim to PR a similar but better tested fix when I get a chance ASAP as a starting point for the maintainers (with a better wholistic understanding of the codebase) to use as a starting point. Stay tuned.
Facing same issue when using gulp-type