Skip to content

Commit a429a02

Browse files
committed
Correct getAlias to always get unique aliases
... even if there's only one entry point. Resolves #1845
1 parent 1357984 commit a429a02

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ These TODOs will be resolved before a full release. ([GitHub project](https://gi
1818

1919
- `@inheritDoc` now follows the behavior specified by TSDoc when copying comments with a reference.
2020
- The `gaSite` option has been removed since Google Analytics now infers the site automatically, updated Google Analytics script to latest version, #1846.
21+
- Comments on export declarations will only overrides comments for references and namespaces, #1901.
2122
- The deprecated `listInvalidSymbolLinks` option has been removed. Use `validation.invalidLink` instead.
2223
- The deprecated `true` and `false` values have been removed from `--emit`, to migrate replace `true` with `"both"` and `false` with `"docs"`.
2324
- Links are no longer be resolved against a global list of all symbols. See [the documentation](https://typedoc.org/guides/link-resolution/) for details on link resolution.
@@ -28,7 +29,6 @@ These TODOs will be resolved before a full release. ([GitHub project](https://gi
2829
- Listeners to `Converter.EVENT_CREATE_TYPE_PARAMETER` and `Converter.EVENT_CREATE_DECLARATION` will now never be passed a `ts.Node` as their third argument.
2930
- Constant variables which are interpreted as functions will no longer have the `ReflectionFlag.Const` flag set.
3031
- Removed deprecated `removeReaderByName`, `addDeclarations` and `removeDeclarationByName` methods on `Options`.
31-
- Comments on export declarations will only overrides comments for references and namespaces, #1901.
3232

3333
### Features
3434

@@ -47,6 +47,7 @@ These TODOs will be resolved before a full release. ([GitHub project](https://gi
4747
- Improved comment discovery on destructured exported functions, #1770.
4848
- Links which refer to members within a reference reflection will now correctly resolve to the referenced reflection's member, #1770.
4949
- Correctly detect optional parameters in JavaScript projects using JSDoc, #1804.
50+
- Fixed identical anchor links for reflections with the same name, #1845.
5051
- JS exports defined as `exports.foo = ...` will now be converted as variables rather than properties.
5152

5253
### Thanks!

src/lib/models/reflections/abstract.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,12 @@ export abstract class Reflection {
414414
alias = "reflection-" + this.id;
415415
}
416416

417-
let target = <Reflection>this;
418-
while (
419-
target.parent &&
420-
!target.parent.isProject() &&
421-
!target.hasOwnDocument
422-
) {
417+
let target = this as Reflection;
418+
while (target.parent && !target.hasOwnDocument) {
423419
target = target.parent;
424420
}
425421

426-
if (!target._aliases) {
427-
target._aliases = new Map();
428-
}
422+
target._aliases ||= new Map();
429423

430424
let suffix = "";
431425
if (!target._aliases.has(alias)) {

src/lib/output/themes/default/DefaultTheme.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ interface TemplateMapping {
2525
*/
2626
kind: ReflectionKind[];
2727

28-
/**
29-
* Can this mapping have children or should all further reflections be rendered
30-
* to the defined output page?
31-
*/
32-
isLeaf: boolean;
33-
3428
/**
3529
* The name of the directory the output files should be written to.
3630
*/
@@ -73,43 +67,36 @@ export class DefaultTheme extends Theme {
7367
private mappings: TemplateMapping[] = [
7468
{
7569
kind: [ReflectionKind.Class],
76-
isLeaf: false,
7770
directory: "classes",
7871
template: this.reflectionTemplate,
7972
},
8073
{
8174
kind: [ReflectionKind.Interface],
82-
isLeaf: false,
8375
directory: "interfaces",
8476
template: this.reflectionTemplate,
8577
},
8678
{
8779
kind: [ReflectionKind.Enum],
88-
isLeaf: false,
8980
directory: "enums",
9081
template: this.reflectionTemplate,
9182
},
9283
{
9384
kind: [ReflectionKind.Namespace, ReflectionKind.Module],
94-
isLeaf: false,
9585
directory: "modules",
9686
template: this.reflectionTemplate,
9787
},
9888
{
9989
kind: [ReflectionKind.TypeAlias],
100-
isLeaf: false,
10190
directory: "types",
10291
template: this.reflectionTemplate,
10392
},
10493
{
10594
kind: [ReflectionKind.Function],
106-
isLeaf: false,
10795
directory: "functions",
10896
template: this.reflectionTemplate,
10997
},
11098
{
11199
kind: [ReflectionKind.Variable],
112-
isLeaf: false,
113100
directory: "variables",
114101
template: this.reflectionTemplate,
115102
},
@@ -225,11 +212,7 @@ export class DefaultTheme extends Theme {
225212
}
226213

227214
for (const child of reflection.children || []) {
228-
if (mapping.isLeaf) {
229-
DefaultTheme.applyAnchorUrl(child, reflection);
230-
} else {
231-
this.buildUrls(child, urls);
232-
}
215+
this.buildUrls(child, urls);
233216
}
234217
} else if (reflection.parent) {
235218
DefaultTheme.applyAnchorUrl(reflection, reflection.parent);

0 commit comments

Comments
 (0)