search.js: give buildIndex a proper return type
some of the fields of rustdoc.Row were confusing null and undefined.
This commit is contained in:
parent
c05f6bf98d
commit
374de12dad
2 changed files with 5 additions and 2 deletions
3
src/librustdoc/html/static/js/rustdoc.d.ts
vendored
3
src/librustdoc/html/static/js/rustdoc.d.ts
vendored
|
@ -182,10 +182,11 @@ declare namespace rustdoc {
|
||||||
name: string,
|
name: string,
|
||||||
normalizedName: string,
|
normalizedName: string,
|
||||||
word: string,
|
word: string,
|
||||||
|
paramNames: string[],
|
||||||
parent: ({ty: number, name: string, path: string, exactPath: string}|null|undefined),
|
parent: ({ty: number, name: string, path: string, exactPath: string}|null|undefined),
|
||||||
path: string,
|
path: string,
|
||||||
ty: number,
|
ty: number,
|
||||||
type?: FunctionSearchType
|
type: FunctionSearchType | null,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1573,7 +1573,6 @@ class DocSearch {
|
||||||
/**
|
/**
|
||||||
* @type {Array<rustdoc.Row>}
|
* @type {Array<rustdoc.Row>}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.searchIndex = this.buildIndex(rawSearchIndex);
|
this.searchIndex = this.buildIndex(rawSearchIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1902,6 +1901,7 @@ class DocSearch {
|
||||||
* Convert raw search index into in-memory search index.
|
* Convert raw search index into in-memory search index.
|
||||||
*
|
*
|
||||||
* @param {Map<string, rustdoc.RawSearchIndexCrate>} rawSearchIndex
|
* @param {Map<string, rustdoc.RawSearchIndexCrate>} rawSearchIndex
|
||||||
|
* @returns {rustdoc.Row[]}
|
||||||
*/
|
*/
|
||||||
buildIndex(rawSearchIndex) {
|
buildIndex(rawSearchIndex) {
|
||||||
/**
|
/**
|
||||||
|
@ -2001,6 +2001,7 @@ class DocSearch {
|
||||||
return cb;
|
return cb;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @type {rustdoc.Row[]} */
|
||||||
const searchIndex = [];
|
const searchIndex = [];
|
||||||
let currentIndex = 0;
|
let currentIndex = 0;
|
||||||
let id = 0;
|
let id = 0;
|
||||||
|
@ -2225,6 +2226,7 @@ class DocSearch {
|
||||||
// object defined above.
|
// object defined above.
|
||||||
const itemParentIdx = itemParentIdxDecoder.next();
|
const itemParentIdx = itemParentIdxDecoder.next();
|
||||||
normalizedName = word.indexOf("_") === -1 ? word : word.replace(/_/g, "");
|
normalizedName = word.indexOf("_") === -1 ? word : word.replace(/_/g, "");
|
||||||
|
/** @type {rustdoc.Row} */
|
||||||
const row = {
|
const row = {
|
||||||
crate,
|
crate,
|
||||||
ty: itemTypes.charCodeAt(i) - 65, // 65 = "A"
|
ty: itemTypes.charCodeAt(i) - 65, // 65 = "A"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue