docascode / type2docfx

A tool to convert json format output from TypeDoc to universal reference model for DocFx to consume.
Apache License 2.0
17 stars 10 forks source link

Getting error "TypeError: Cannot read property 'items' of undefined" #63

Open hdi-amiri opened 3 years ago

hdi-amiri commented 3 years ago

I am using this library with TypeDoc 0.20.26, I get the json output by setting "json": "json-doc" inside my tsconfig.json file and output is generated. But when I want to use it by entering following command to get the yaml output, I get the error that follows:

type2docfx json-doc.json yaml-dir

$ type2docfx json-doc.json .                                                                            
Warning: nothing genereatd.
Yaml dump start.
Yaml dump end.
Package index generated.
C:\Users\User1\AppData\Roaming\npm\node_modules\type2docfx\dist\main.js:126
var toc = tocGenerator_1.generateTOC(rootElementsForTOC, flattenElements[0].items[0].package);
                                                                            ^

TypeError: Cannot read property 'items' of undefined
    at Object.<anonymous> (C:\Users\User1\AppData\Roaming\npm\node_modules\type2docfx\dist\main.js:126:77)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

type2docfx version: v0.11.2

iJungleboy commented 3 years ago

Same issue here.

iJungleboy commented 3 years ago

Just for better debugging here's a copy of my json which couldn't be parsed (I had to rename to .txt so I could upload on github)

dnn-sxc-angular.json.txt

lishali-fm commented 3 years ago

I have the same issue.

hiepsolo commented 3 years ago

Same issue here.

JordoHeffernan commented 3 years ago

Did anyone figure out a fix for this? I'm running into a similar problem.

XannMagus commented 3 years ago

I'm still having the same issue as well

Gankarloo commented 3 years ago

Same issue for me to.

yunair commented 3 years ago

@hadiamiri could you tell me which version of docfx your use?

SebHoffmRS commented 3 years ago

same problem here. the isExported flag is missing from the top-level nodes (just like in @iJungleboy 's case file), and I have no idea how to change this.

This is where everything is ignored: https://github.com/docascode/type2docfx/blob/v0.10.5/src/parser.ts#L60

@yunair I use typedoc 0.21.5, type2docfx 0.11.2, and docfx 2.58.0 (btw: why is the docfx version interesting?)

I also don't understand why type2docfx's latest version is 0.11.2 on npmjs.org and the latest version in this repo seems to be 0.10.5.

SebHoffmRS commented 3 years ago

possibly related: TypeStrong/typedoc#888

SebHoffmRS commented 3 years ago

As noted in TypeStrong/typedoc#888 ,

The isExported flag was removed in 0.20. TypeDoc only documents exported members now.

See also the release notes https://github.com/TypeStrong/typedoc/releases/tag/v0.20.0 :

isExported / isConstructorProperty ReflectionFlags remvoed

So ignoring nodes without this flag set to true has become incompatible: https://github.com/docascode/type2docfx/blob/v0.10.5/src/parser.ts#L60

yunair commented 3 years ago

same problem here. the isExported flag is missing from the top-level nodes (just like in @iJungleboy 's case file), and I have no idea how to change this.

This is where everything is ignored: https://github.com/docascode/type2docfx/blob/v0.10.5/src/parser.ts#L60

@yunair I use typedoc 0.21.5, type2docfx 0.11.2, and docfx 2.58.0 (btw: why is the docfx version interesting?)

I also don't understand why type2docfx's latest version is 0.11.2 on npmjs.org and the latest version in this repo seems to be 0.10.5.

Because when you use docfx V2, the corresponding version of type2docfx is 0.10.X. when you use docfx V3, you need to use a version higher than 0.11.0

yunair commented 3 years ago

The latest version of typedoc that type2docfx support is 0.15 because new version of typedoc change the rule of uid generator, then we can't simply upgrade typedoc.

so if you use docfx V2, you need to install typedoc@0.15.0 and type2docfx@0.10.5. if you use docfx V3, you need to install typedoc@0.15.0 and type2docfx

SebHoffmRS commented 3 years ago

thanks for the information!