Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions sphinx_js/js/convertTopLevel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,19 @@ class PathComputer implements ReflectionVisitor {
*/
function renderCommentContent(content: CommentDisplayPart[]): Description {
return content.map((x): DescriptionItem => {
if (x.kind === "code") {
return { type: "code", code: x.text };
switch (x.kind) {
case "code":
return { type: "code", code: x.text };
case "text":
return { type: "text", text: x.text };
// TODO: Add to DescriptionItem
case "inline-tag":
return { type: "text", text: x.text };
case "relative-link":
return { type: "text", text: x.text };
default:
throw new Error("Not implemented");
Comment on lines +267 to +268
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not include this default case because then the typescript typechecker will give a type error if there are cases that we haven't covered.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the default case, TypeScript requires the return value to be Array<DescriptionItem | undefined>. Is that what we want?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it works fine. Did you run npm i?

Copy link
Member

@hoodmane hoodmane Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #276:
https://github.com/pyodide/sphinx-js/actions/runs/16121106961/job/45486860109#step:6:31
It should typecheck fine if your development environment is set up correctly.

Copy link
Author

@laymonage laymonage Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry about that, thanks! It does work after that, but now it detects relative-link being incorrect because it was added in typedoc 0.26, while our package.json uses typedoc ^0.25.13.

Would you rather drop relative-link, or update typedoc (or maybe add a version check...)? (Also, it seems package-lock.json needs updating...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can skip the typecheck job against typedoc 0.25 and only run it on the 0.27 and 0.28 jobs.

}
if (x.kind === "text") {
return { type: "text", text: x.text };
}
throw new Error("Not implemented");
});
}

Expand Down
6 changes: 5 additions & 1 deletion sphinx_js/js/redirectPrivateAliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ export function redirectPrivateTypes(app: Application): ReadonlySymbolToType {

const missing = discoverMissingExports(mod, context);
for (const name of missing) {
const decl = name.declarations![0];
// Some symbols e.g. JSX.LibraryManagedAttributes have no declarations
if (!name.declarations || name.declarations.length === 0) {
continue;
}
Comment on lines +170 to +173
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comes from React, declarations was undefined.

const decl = name.declarations[0];
if (decl.getSourceFile().fileName.includes("node_modules")) {
continue;
}
Expand Down
Loading