Skip to content

Commit 7421546

Browse files
committed
main.js: typecheck things related to window.register_type_impls
1 parent 749b6bf commit 7421546

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Diff for: src/librustdoc/html/static/js/main.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -797,16 +797,14 @@ function preLoadCss(cssUrl) {
797797
*
798798
* - After processing all of the impls, it sorts the sidebar items by name.
799799
*
800-
* @param {{[cratename: string]: Array<Array<string|0>>}} imp
800+
* @param {rustdoc.TypeImpls} imp
801801
*/
802-
// @ts-expect-error
803802
window.register_type_impls = imp => {
804803
// @ts-expect-error
805804
if (!imp || !imp[window.currentCrate]) {
806805
return;
807806
}
808-
// @ts-expect-error
809-
window.pending_type_impls = null;
807+
window.pending_type_impls = undefined;
810808
const idMap = new Map();
811809

812810
let implementations = document.getElementById("implementations-list");
@@ -992,9 +990,7 @@ function preLoadCss(cssUrl) {
992990
list.replaceChildren(...newChildren);
993991
}
994992
};
995-
// @ts-expect-error
996993
if (window.pending_type_impls) {
997-
// @ts-expect-error
998994
window.register_type_impls(window.pending_type_impls);
999995
}
1000996

Diff for: src/librustdoc/html/static/js/rustdoc.d.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ declare global {
4848
* register trait implementors, called by code generated in
4949
* `write_shared.rs`
5050
*/
51-
register_implementors?: function(Implementors): void,
51+
register_implementors?: function(rustdoc.Implementors): void,
5252
/**
5353
* fallback in case `register_implementors` isn't defined yet.
5454
*/
55-
pending_implementors?: Implementors,
55+
pending_implementors?: rustdoc.Implementors,
56+
register_type_impls?: function(rustdoc.TypeImpls): void,
57+
pending_type_impls?: rustdoc.TypeImpls,
5658
}
5759
interface HTMLElement {
5860
/** Used by the popover tooltip code. */
@@ -432,4 +434,8 @@ declare namespace rustdoc {
432434
type Implementors = {
433435
[key: string]: Array<[string, number, Array<string>]>
434436
}
437+
438+
type TypeImpls = {
439+
[cratename: string]: Array<Array<string|0>>
440+
}
435441
}

0 commit comments

Comments
 (0)