Skip to content

Commit 374de12

Browse files
committed
search.js: give buildIndex a proper return type
some of the fields of rustdoc.Row were confusing null and undefined.
1 parent c05f6bf commit 374de12

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/librustdoc/html/static/js/rustdoc.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,11 @@ declare namespace rustdoc {
182182
name: string,
183183
normalizedName: string,
184184
word: string,
185+
paramNames: string[],
185186
parent: ({ty: number, name: string, path: string, exactPath: string}|null|undefined),
186187
path: string,
187188
ty: number,
188-
type?: FunctionSearchType
189+
type: FunctionSearchType | null,
189190
}
190191

191192
/**

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,6 @@ class DocSearch {
15731573
/**
15741574
* @type {Array<rustdoc.Row>}
15751575
*/
1576-
// @ts-expect-error
15771576
this.searchIndex = this.buildIndex(rawSearchIndex);
15781577
}
15791578

@@ -1902,6 +1901,7 @@ class DocSearch {
19021901
* Convert raw search index into in-memory search index.
19031902
*
19041903
* @param {Map<string, rustdoc.RawSearchIndexCrate>} rawSearchIndex
1904+
* @returns {rustdoc.Row[]}
19051905
*/
19061906
buildIndex(rawSearchIndex) {
19071907
/**
@@ -2001,6 +2001,7 @@ class DocSearch {
20012001
return cb;
20022002
};
20032003

2004+
/** @type {rustdoc.Row[]} */
20042005
const searchIndex = [];
20052006
let currentIndex = 0;
20062007
let id = 0;
@@ -2225,6 +2226,7 @@ class DocSearch {
22252226
// object defined above.
22262227
const itemParentIdx = itemParentIdxDecoder.next();
22272228
normalizedName = word.indexOf("_") === -1 ? word : word.replace(/_/g, "");
2229+
/** @type {rustdoc.Row} */
22282230
const row = {
22292231
crate,
22302232
ty: itemTypes.charCodeAt(i) - 65, // 65 = "A"

0 commit comments

Comments
 (0)