diff options
| author | binarycat <binarycat@envs.net> | 2025-03-04 15:19:20 -0600 |
|---|---|---|
| committer | binarycat <binarycat@envs.net> | 2025-03-04 15:19:20 -0600 |
| commit | 374de12dad8e42e1595f1af5f8e43b8b2b71c61c (patch) | |
| tree | 7ad92d4f1f42e1ee884d54ecf67fdd82072147e8 | |
| parent | c05f6bf98d08cfb159051caaae850590758f6c15 (diff) | |
| download | rust-374de12dad8e42e1595f1af5f8e43b8b2b71c61c.tar.gz rust-374de12dad8e42e1595f1af5f8e43b8b2b71c61c.zip | |
search.js: give buildIndex a proper return type
some of the fields of rustdoc.Row were confusing null and undefined.
| -rw-r--r-- | src/librustdoc/html/static/js/rustdoc.d.ts | 3 | ||||
| -rw-r--r-- | src/librustdoc/html/static/js/search.js | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/librustdoc/html/static/js/rustdoc.d.ts b/src/librustdoc/html/static/js/rustdoc.d.ts index bc4c9a12ac0..060d8205658 100644 --- a/src/librustdoc/html/static/js/rustdoc.d.ts +++ b/src/librustdoc/html/static/js/rustdoc.d.ts @@ -182,10 +182,11 @@ declare namespace rustdoc { name: string, normalizedName: string, word: string, + paramNames: string[], parent: ({ty: number, name: string, path: string, exactPath: string}|null|undefined), path: string, ty: number, - type?: FunctionSearchType + type: FunctionSearchType | null, } /** diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 9d740cef3eb..ccaa8237ff8 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -1573,7 +1573,6 @@ class DocSearch { /** * @type {Array<rustdoc.Row>} */ - // @ts-expect-error this.searchIndex = this.buildIndex(rawSearchIndex); } @@ -1902,6 +1901,7 @@ class DocSearch { * Convert raw search index into in-memory search index. * * @param {Map<string, rustdoc.RawSearchIndexCrate>} rawSearchIndex + * @returns {rustdoc.Row[]} */ buildIndex(rawSearchIndex) { /** @@ -2001,6 +2001,7 @@ class DocSearch { return cb; }; + /** @type {rustdoc.Row[]} */ const searchIndex = []; let currentIndex = 0; let id = 0; @@ -2225,6 +2226,7 @@ class DocSearch { // object defined above. const itemParentIdx = itemParentIdxDecoder.next(); normalizedName = word.indexOf("_") === -1 ? word : word.replace(/_/g, ""); + /** @type {rustdoc.Row} */ const row = { crate, ty: itemTypes.charCodeAt(i) - 65, // 65 = "A" |
