Skip to content

Rustdoc: remove a bunch of @ts-expect-error from main.js #138318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
rustdoc.d.ts: add window.{register_implementors,pending_implementors}
  • Loading branch information
lolbinarycat committed Mar 10, 2025
commit 749b6bf79f0fb1cfa3d2ba12f3ae2f1cf0f374d0
3 changes: 0 additions & 3 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ function preLoadCss(cssUrl) {
}

// <https://github.com/search?q=repo%3Arust-lang%2Frust+[RUSTDOCIMPL]+trait.impl&type=code>
// @ts-expect-error
window.register_implementors = imp => {
const implementors = document.getElementById("implementors-list");
const synthetic_implementors = document.getElementById("synthetic-implementors-list");
Expand Down Expand Up @@ -765,9 +764,7 @@ function preLoadCss(cssUrl) {
}
}
};
// @ts-expect-error
if (window.pending_implementors) {
// @ts-expect-error
window.register_implementors(window.pending_implementors);
}

Expand Down
17 changes: 17 additions & 0 deletions src/librustdoc/html/static/js/rustdoc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ declare global {
* Set up event listeners for a scraped source example.
*/
updateScrapedExample?: function(HTMLElement, HTMLElement),
/**
* register trait implementors, called by code generated in
* `write_shared.rs`
*/
register_implementors?: function(Implementors): void,
/**
* fallback in case `register_implementors` isn't defined yet.
*/
pending_implementors?: Implementors,
}
interface HTMLElement {
/** Used by the popover tooltip code. */
Expand Down Expand Up @@ -415,4 +424,12 @@ declare namespace rustdoc {
};

type VlqData = VlqData[] | number;

/**
* Maps from crate names to trait implementation data.
* Provied by generated `trait.impl` files.
*/
type Implementors = {
[key: string]: Array<[string, number, Array<string>]>
}
}