Skip to content

Commit a012e21

Browse files
committed
rustdoc js: typecheck sortQ
1 parent 76c4947 commit a012e21

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/librustdoc/html/static/js/search.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4587,18 +4587,16 @@ class DocSearch {
45874587
// types with generic parameters go last.
45884588
// That's because of the way unification is structured: it eats off
45894589
// the end, and hits a fast path if the last item is a simple atom.
4590-
// @ts-expect-error
4590+
/** @type {function(rustdoc.QueryElement, rustdoc.QueryElement): number} */
45914591
const sortQ = (a, b) => {
45924592
const ag = a.generics.length === 0 && a.bindings.size === 0;
45934593
const bg = b.generics.length === 0 && b.bindings.size === 0;
45944594
if (ag !== bg) {
4595-
// @ts-expect-error
4596-
return ag - bg;
4595+
return +ag - +bg;
45974596
}
4598-
const ai = a.id > 0;
4599-
const bi = b.id > 0;
4600-
// @ts-expect-error
4601-
return ai - bi;
4597+
const ai = a.id !== null && a.id > 0;
4598+
const bi = b.id !== null && b.id > 0;
4599+
return +ai - +bi;
46024600
};
46034601
parsedQuery.elems.sort(sortQ);
46044602
parsedQuery.returned.sort(sortQ);

0 commit comments

Comments
 (0)