diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-03 23:50:58 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-03 23:50:58 +0800 |
commit | 9e7b45ea4cf8d0fabec5f293efc448262e0a7cb2 (patch) | |
tree | 46af50d0ba08d4a31911a454c0f6493e8f955377 /packages/website/ts | |
parent | 6c6bd60a483220706bdecf31b1eef3dc637fade9 (diff) | |
download | dexon-sol-tools-9e7b45ea4cf8d0fabec5f293efc448262e0a7cb2.tar.gz dexon-sol-tools-9e7b45ea4cf8d0fabec5f293efc448262e0a7cb2.tar.zst dexon-sol-tools-9e7b45ea4cf8d0fabec5f293efc448262e0a7cb2.zip |
Add support for backward compatibility for TypeDoc versions <0.9.0
Diffstat (limited to 'packages/website/ts')
-rw-r--r-- | packages/website/ts/types.ts | 2 | ||||
-rw-r--r-- | packages/website/ts/utils/typedoc_utils.ts | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index f0db537e6..5786787c0 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -308,7 +308,7 @@ export interface TypeDocNode { returns?: string; declaration: TypeDocNode; flags?: TypeDocFlags; - indexSignature?: TypeDocNode[]; + indexSignature?: TypeDocNode | TypeDocNode[]; signatures?: TypeDocNode[]; parameters?: TypeDocNode[]; typeParameter?: TypeDocNode[]; diff --git a/packages/website/ts/utils/typedoc_utils.ts b/packages/website/ts/utils/typedoc_utils.ts index 992475911..0f79410ae 100644 --- a/packages/website/ts/utils/typedoc_utils.ts +++ b/packages/website/ts/utils/typedoc_utils.ts @@ -170,8 +170,16 @@ export const typeDocUtils = { const methodIfExists = !_.isUndefined(entity.declaration) ? typeDocUtils._convertMethod(entity.declaration, isConstructor, sections, sectionName, docId) : undefined; - const indexSignatureIfExists = !_.isUndefined(entity.indexSignature) - ? typeDocUtils._convertIndexSignature(entity.indexSignature[0], sections, sectionName, docId) + const doesIndexSignatureExist = !_.isUndefined(entity.indexSignature); + const isIndexSignatureArray = _.isArray(entity.indexSignature); + // HACK: TypeDoc Versions <0.9.0 indexSignature is of type TypeDocNode[] + // Versions >0.9.0 have it as type TypeDocNode + const indexSignature = + doesIndexSignatureExist && isIndexSignatureArray + ? ((entity.indexSignature as TypeDocNode[])[0] as TypeDocNode) + : (entity.indexSignature as TypeDocNode); + const indexSignatureIfExists = doesIndexSignatureExist + ? typeDocUtils._convertIndexSignature(indexSignature, sections, sectionName, docId) : undefined; const commentIfExists = !_.isUndefined(entity.comment) && !_.isUndefined(entity.comment.shortText) |