Skip to content

Commit

Permalink
Handle symbols in implementationOf
Browse files Browse the repository at this point in the history
Resolves #2234
  • Loading branch information
Gerrit0 committed Apr 15, 2023
1 parent 882ceff commit f6dc882
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Fixed semantic coloring in type and function signatures, #2227.
- Fixed issue where removing a reflection indirectly containing an object/function type would only partially remove the reflection, #2231.
- Fixed "Implementation of X.y" links if a mixture of methods and property-methods are used, #2233.
- "Implementation of" text to symbol-properties not contained in the documentation will now use the resolved name instead of a `__@` symbol name, #2234.
- Fix expansion of globs if a single entry point is provided, #2235.
- Fixed broken theme toggle if the page contained a member named "theme".

Expand Down
3 changes: 2 additions & 1 deletion src/lib/converter/plugins/ImplementsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { filterMap, zip } from "../../utils/array";
import { Component, ConverterComponent } from "../components";
import type { Context } from "../context";
import { Converter } from "../converter";
import { getHumanName } from "../../utils";

/**
* A plugin that detects interface implementations of functions and
Expand Down Expand Up @@ -405,7 +406,7 @@ function createLink(
isOverwrite: boolean
) {
const project = context.project;
const name = `${expr.expression.getText()}.${symbol.name}`;
const name = `${expr.expression.getText()}.${getHumanName(symbol.name)}`;

link(reflection);
link(reflection.getSignature);
Expand Down
11 changes: 11 additions & 0 deletions src/test/converter2/issues/gh2234.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface ReadonlyCharMap extends Iterable<string> {
at(x: number): string;
}

export class CharMap implements ReadonlyCharMap {
at() {
return "";
}

*[Symbol.iterator](): Iterator<string> {}
}
14 changes: 14 additions & 0 deletions src/test/issues.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1079,4 +1079,18 @@ describe("Issue Tests", () => {
);
}
});

it("Handles implementationOf with symbols #2234", () => {
const project = convert();
const cm = query(project, "CharMap");
equal(
cm.children?.map((c) => c.name),
["constructor", "[iterator]", "at"]
);

equal(
cm.children[1].implementationOf?.name,
"ReadonlyCharMap.[iterator]"
);
});
});

0 comments on commit f6dc882

Please sign in to comment.