Skip to content

Commit

Permalink
Small code cleanup that would get caught in code review
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewJakubowicz committed May 4, 2023
1 parent fd12058 commit 15047da
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/lit-dev-tools-cjs/src/api-docs/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ export class ApiDocsTransformer {
symbolMap: SymbolMap;
pages: Pages;
}> {
this.addKindStringsBackToAllNodes(
this.project as unknown as Record<string, unknown>
);
this.addKindStringsBackToAllNodes(this.project);
// In the first pass, determine the page/anchor where each node should
// appear in our layout, and index all nodes by TypeDoc numeric ID.
for (const entrypoint of this.project.children ?? []) {
Expand Down Expand Up @@ -694,7 +692,7 @@ export class ApiDocsTransformer {
* api.html. This method recursively walks the TypeDoc node and adds
* `kindString` back to all nodes with a valid `kind` field.
*/
private addKindStringsBackToAllNodes(node: Record<string, unknown>) {
private addKindStringsBackToAllNodes(node: unknown) {
if (typeof node !== 'object' || node == null) {
return;
}
Expand All @@ -707,11 +705,10 @@ export class ApiDocsTransformer {
for (const [key, val] of Object.entries(node)) {
if (key === 'kind' && typeof val === 'number') {
// Add a `kindString` field to the node.
node['kindString'] = typedoc.ReflectionKind.singularString(
val as ReflectionKind
);
(node as {kindString: string})['kindString'] =
typedoc.ReflectionKind.singularString(val as ReflectionKind);
}
this.addKindStringsBackToAllNodes(val as Record<string, unknown>);
this.addKindStringsBackToAllNodes(val);
}
}

Expand Down

0 comments on commit 15047da

Please sign in to comment.