Skip to content

Commit 549ba06

Browse files
committed
main.js: typecheck things related to window.register_type_impls
1 parent b4d123a commit 549ba06

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
@@ -800,16 +800,14 @@ function preLoadCss(cssUrl) {
800800
*
801801
* - After processing all of the impls, it sorts the sidebar items by name.
802802
*
803-
* @param {{[cratename: string]: Array<Array<string|0>>}} imp
803+
* @param {rustdoc.TypeImpls} imp
804804
*/
805-
// @ts-expect-error
806805
window.register_type_impls = imp => {
807806
// @ts-expect-error
808807
if (!imp || !imp[window.currentCrate]) {
809808
return;
810809
}
811-
// @ts-expect-error
812-
window.pending_type_impls = null;
810+
window.pending_type_impls = undefined;
813811
const idMap = new Map();
814812

815813
let implementations = document.getElementById("implementations-list");
@@ -995,9 +993,7 @@ function preLoadCss(cssUrl) {
995993
list.replaceChildren(...newChildren);
996994
}
997995
};
998-
// @ts-expect-error
999996
if (window.pending_type_impls) {
1000-
// @ts-expect-error
1001997
window.register_type_impls(window.pending_type_impls);
1002998
}
1003999

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)