Skip to content

Commit 16b4ccc

Browse files
committed
Fix typescript error
1 parent e0cc467 commit 16b4ccc

File tree

1 file changed

+83
-84
lines changed

1 file changed

+83
-84
lines changed

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

Lines changed: 83 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,89 +2103,6 @@ class DocSearch {
21032103
return tmp;
21042104
}
21052105

2106-
/**
2107-
* Add extra data to result objects, and filter items that have been
2108-
* marked for removal.
2109-
*
2110-
* @param {[rustdoc.PlainResultObject, rustdoc.Row][]} results
2111-
* @param {"sig"|"elems"|"returned"|null} typeInfo
2112-
* @param {Set<string>} duplicates
2113-
* @returns {rustdoc.ResultObject[]}
2114-
*/
2115-
const transformResults = (results, typeInfo, duplicates) => {
2116-
const out = [];
2117-
2118-
for (const [result, item] of results) {
2119-
if (item.id !== -1) {
2120-
const res = buildHrefAndPath(item);
2121-
// many of these properties don't strictly need to be
2122-
// copied over, but copying them over satisfies tsc,
2123-
// and hopefully plays nice with the shape optimization
2124-
// of the browser engine.
2125-
/** @type {rustdoc.ResultObject} */
2126-
const obj = Object.assign({
2127-
parent: item.parent ? {
2128-
path: item.parent.path.modulePath,
2129-
exactPath: item.parent.path.exactModulePath ||
2130-
item.parent.path.modulePath,
2131-
name: item.parent.name,
2132-
ty: item.parent.path.ty,
2133-
} : undefined,
2134-
type: item.type && item.type.functionSignature ?
2135-
item.type.functionSignature :
2136-
undefined,
2137-
paramNames: item.type && item.type.paramNames ?
2138-
item.type.paramNames :
2139-
undefined,
2140-
dist: result.dist,
2141-
path_dist: result.path_dist,
2142-
index: result.index,
2143-
desc: this.getDesc(result.id),
2144-
item,
2145-
displayPath: pathSplitter(res[0]),
2146-
fullPath: "",
2147-
href: "",
2148-
displayTypeSignature: null,
2149-
}, result);
2150-
2151-
// To be sure than it some items aren't considered as duplicate.
2152-
obj.fullPath = res[2] + "|" + obj.item.ty;
2153-
2154-
if (duplicates.has(obj.fullPath)) {
2155-
continue;
2156-
}
2157-
2158-
// Exports are specifically not shown if the items they point at
2159-
// are already in the results.
2160-
if (obj.item.ty === TY_IMPORT && duplicates.has(res[2])) {
2161-
continue;
2162-
}
2163-
if (duplicates.has(res[2] + "|" + TY_IMPORT)) {
2164-
continue;
2165-
}
2166-
duplicates.add(obj.fullPath);
2167-
duplicates.add(res[2]);
2168-
2169-
if (typeInfo !== null) {
2170-
// @ts-expect-error
2171-
obj.displayTypeSignature = this.formatDisplayTypeSignature(
2172-
obj,
2173-
typeInfo,
2174-
result.elems,
2175-
result.returned,
2176-
);
2177-
}
2178-
2179-
obj.href = res[1];
2180-
out.push(obj);
2181-
if (out.length >= MAX_RESULTS) {
2182-
break;
2183-
}
2184-
}
2185-
}
2186-
return out;
2187-
};
2188-
21892106
/**
21902107
* Add extra data to result objects, and filter items that have been
21912108
* marked for removal.
@@ -2199,7 +2116,7 @@ class DocSearch {
21992116
* @param {rustdoc.QueryElement[]} returned
22002117
* @returns {Promise<rustdoc.DisplayTypeSignature>}
22012118
*/
2202-
this.formatDisplayTypeSignature = async(obj, typeInfo, elems, returned) => {
2119+
const formatDisplayTypeSignature = async(obj, typeInfo, elems, returned) => {
22032120
const objType = obj.type;
22042121
if (!objType) {
22052122
return {type: [], mappedNames: new Map(), whereClause: new Map()};
@@ -2569,6 +2486,88 @@ class DocSearch {
25692486
return {type, mappedNames, whereClause};
25702487
};
25712488

2489+
/**
2490+
* Add extra data to result objects, and filter items that have been
2491+
* marked for removal.
2492+
*
2493+
* @param {[rustdoc.PlainResultObject, rustdoc.Row][]} results
2494+
* @param {"sig"|"elems"|"returned"|null} typeInfo
2495+
* @param {Set<string>} duplicates
2496+
* @returns {rustdoc.ResultObject[]}
2497+
*/
2498+
const transformResults = (results, typeInfo, duplicates) => {
2499+
const out = [];
2500+
2501+
for (const [result, item] of results) {
2502+
if (item.id !== -1) {
2503+
const res = buildHrefAndPath(item);
2504+
// many of these properties don't strictly need to be
2505+
// copied over, but copying them over satisfies tsc,
2506+
// and hopefully plays nice with the shape optimization
2507+
// of the browser engine.
2508+
/** @type {rustdoc.ResultObject} */
2509+
const obj = Object.assign({
2510+
parent: item.parent ? {
2511+
path: item.parent.path.modulePath,
2512+
exactPath: item.parent.path.exactModulePath ||
2513+
item.parent.path.modulePath,
2514+
name: item.parent.name,
2515+
ty: item.parent.path.ty,
2516+
} : undefined,
2517+
type: item.type && item.type.functionSignature ?
2518+
item.type.functionSignature :
2519+
undefined,
2520+
paramNames: item.type && item.type.paramNames ?
2521+
item.type.paramNames :
2522+
undefined,
2523+
dist: result.dist,
2524+
path_dist: result.path_dist,
2525+
index: result.index,
2526+
desc: this.getDesc(result.id),
2527+
item,
2528+
displayPath: pathSplitter(res[0]),
2529+
fullPath: "",
2530+
href: "",
2531+
displayTypeSignature: null,
2532+
}, result);
2533+
2534+
// To be sure than it some items aren't considered as duplicate.
2535+
obj.fullPath = res[2] + "|" + obj.item.ty;
2536+
2537+
if (duplicates.has(obj.fullPath)) {
2538+
continue;
2539+
}
2540+
2541+
// Exports are specifically not shown if the items they point at
2542+
// are already in the results.
2543+
if (obj.item.ty === TY_IMPORT && duplicates.has(res[2])) {
2544+
continue;
2545+
}
2546+
if (duplicates.has(res[2] + "|" + TY_IMPORT)) {
2547+
continue;
2548+
}
2549+
duplicates.add(obj.fullPath);
2550+
duplicates.add(res[2]);
2551+
2552+
if (typeInfo !== null) {
2553+
obj.displayTypeSignature = formatDisplayTypeSignature(
2554+
obj,
2555+
typeInfo,
2556+
result.elems,
2557+
result.returned,
2558+
);
2559+
}
2560+
2561+
obj.href = res[1];
2562+
out.push(obj);
2563+
if (out.length >= MAX_RESULTS) {
2564+
break;
2565+
}
2566+
}
2567+
}
2568+
return out;
2569+
};
2570+
25722571
const sortAndTransformResults =
25732572
/**
25742573
* @this {DocSearch}

0 commit comments

Comments
 (0)