Skip to content

Commit 68fc6e1

Browse files
fix(typedoc-0.14): Improve typedoc 0.14.0 compatibility to account for api change
This accounts for an API change in DeclarationReflection constructor which is used when creating a parent.child typedoc module
1 parent b983efd commit 68fc6e1

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@
1919
},
2020
"author": "Chris Thielen",
2121
"license": "MIT",
22+
"dependencies": {
23+
"semver": "^7.1.1"
24+
},
2225
"peerDependencies": {
2326
"typedoc": ">=0.7.0 <0.15.0"
2427
},
2528
"devDependencies": {
2629
"@types/handlebars": "^4.0.37",
30+
"@types/semver": "^6.2.0",
2731
"@uirouter/publish-scripts": "^2.3.24",
2832
"husky": "^2.2.0",
2933
"prettier": "^1.13.7",

plugin.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import { ContainerReflection } from 'typedoc/dist/lib/models/reflections/contain
88
import { DeclarationReflection } from 'typedoc/dist/lib/models/reflections/declaration';
99
import { getRawComment } from './getRawComment';
1010

11+
import { satisfies } from 'semver';
12+
const version = require('typedoc/package.json').version;
13+
const useOldDeclarationReflectionConstructor = satisfies(version, '< 0.14.0');
14+
1115
/**
1216
* This plugin allows an ES6 module to specify its TypeDoc name.
1317
* It also allows multiple ES6 modules to be merged together into a single TypeDoc module.
@@ -109,7 +113,12 @@ export class ExternalModuleNamePlugin extends ConverterComponent {
109113
for (let i = 0; i < nameParts.length - 1; ++i) {
110114
let child: DeclarationReflection = parent.children.filter(ref => ref.name === nameParts[i])[0];
111115
if (!child) {
112-
child = new DeclarationReflection(parent, nameParts[i], ReflectionKind.ExternalModule);
116+
if (useOldDeclarationReflectionConstructor) {
117+
// for typedoc < 0.15.0
118+
child = new (DeclarationReflection as any)(parent, nameParts[i], ReflectionKind.ExternalModule);
119+
} else {
120+
child = new DeclarationReflection(nameParts[i], ReflectionKind.ExternalModule, parent);
121+
}
113122
child.parent = parent;
114123
child.children = [];
115124
context.project.reflections[child.id] = child;

yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
5757
integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==
5858

59+
"@types/semver@^6.2.0":
60+
version "6.2.0"
61+
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.0.tgz#d688d574400d96c5b0114968705366f431831e1a"
62+
integrity sha512-1OzrNb4RuAzIT7wHSsgZRlMBlNsJl+do6UblR7JMW4oB7bbR+uBEYtUh7gEc/jM84GGilh68lSOokyM/zNUlBA==
63+
5964
"@types/shelljs@^0.8.0":
6065
version "0.8.1"
6166
resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.8.1.tgz#133e874b5fb816a2e1c8647839c82d76760b1191"
@@ -1716,6 +1721,11 @@ semver-compare@^1.0.0:
17161721
version "5.5.0"
17171722
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
17181723

1724+
semver@^7.1.1:
1725+
version "7.1.1"
1726+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.1.1.tgz#29104598a197d6cbe4733eeecbe968f7b43a9667"
1727+
integrity sha512-WfuG+fl6eh3eZ2qAf6goB7nhiCd7NPXhmyFxigB/TOkQyeLP8w8GsVehvtGNtnNmyboz4TgeK40B1Kbql/8c5A==
1728+
17191729
set-blocking@^2.0.0:
17201730
version "2.0.0"
17211731
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"

0 commit comments

Comments
 (0)