Skip to content

Commit f6dc882

Browse files
committed
Handle symbols in implementationOf
Resolves #2234
1 parent 882ceff commit f6dc882

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- Fixed semantic coloring in type and function signatures, #2227.
2222
- Fixed issue where removing a reflection indirectly containing an object/function type would only partially remove the reflection, #2231.
2323
- Fixed "Implementation of X.y" links if a mixture of methods and property-methods are used, #2233.
24+
- "Implementation of" text to symbol-properties not contained in the documentation will now use the resolved name instead of a `__@` symbol name, #2234.
2425
- Fix expansion of globs if a single entry point is provided, #2235.
2526
- Fixed broken theme toggle if the page contained a member named "theme".
2627

src/lib/converter/plugins/ImplementsPlugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { filterMap, zip } from "../../utils/array";
1313
import { Component, ConverterComponent } from "../components";
1414
import type { Context } from "../context";
1515
import { Converter } from "../converter";
16+
import { getHumanName } from "../../utils";
1617

1718
/**
1819
* A plugin that detects interface implementations of functions and
@@ -405,7 +406,7 @@ function createLink(
405406
isOverwrite: boolean
406407
) {
407408
const project = context.project;
408-
const name = `${expr.expression.getText()}.${symbol.name}`;
409+
const name = `${expr.expression.getText()}.${getHumanName(symbol.name)}`;
409410

410411
link(reflection);
411412
link(reflection.getSignature);

src/test/converter2/issues/gh2234.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export interface ReadonlyCharMap extends Iterable<string> {
2+
at(x: number): string;
3+
}
4+
5+
export class CharMap implements ReadonlyCharMap {
6+
at() {
7+
return "";
8+
}
9+
10+
*[Symbol.iterator](): Iterator<string> {}
11+
}

src/test/issues.c2.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,4 +1079,18 @@ describe("Issue Tests", () => {
10791079
);
10801080
}
10811081
});
1082+
1083+
it("Handles implementationOf with symbols #2234", () => {
1084+
const project = convert();
1085+
const cm = query(project, "CharMap");
1086+
equal(
1087+
cm.children?.map((c) => c.name),
1088+
["constructor", "[iterator]", "at"]
1089+
);
1090+
1091+
equal(
1092+
cm.children[1].implementationOf?.name,
1093+
"ReadonlyCharMap.[iterator]"
1094+
);
1095+
});
10821096
});

0 commit comments

Comments
 (0)