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

TypeError: Cannot read property '0' of undefined in jsonTraverse.js:474 #31

Closed GaloisGirl closed 5 years ago

GaloisGirl commented 5 years ago

Actual behavior

When running it on a file generated by Typedoc@0.14.0 which contains "type": "reflection", the following error is thrown:

C:\Users\awroc\AppData\Roaming\npm\node_modules\type2docfx\dist\jsonTraverse.js:474
                        typeName: signatures.parameters[0].type.name,
                                                       ^
TypeError: Cannot read property '0' of undefined

Expected behavior

No error is thrown, output is generated.

Versions

Occurs in type2docfx@0.9.114. Occurs with typedoc@0.14.0 but not typedoc@0.13.0

Cause

The code expects indexSignature to be an object and not an array:

let signatures = type.declaration.indexSignature;

and:

typeName: signatures.parameters[0].type.name,

However, Typedoc generates an array since version 0.14.0: https://github.com/TypeStrong/typedoc/pull/721

greggbjensen commented 5 years ago

I also ran into this issue, and fixed this with pull request #43. If that can be merged, it would be appreciated.

qinezh commented 5 years ago

Thanks @greggbjensen , PR is merged and new version released, please have a try 😄