当我将TypeScript与Semantic UI search函数一起使用时,即使存在参数“fullTextSearch”,也会出现以下错误。为什么TypeScript在那里却看不到?
代码
$('#'+this.uiSearch.id)
.search({
name: this.name+' Search',
namespace: "search"+this.uiSearch.id,
type: 'category',
source: categoryContent,
fullTextSearch: "exact",
maxResults: 30,
searchFields: ["category", "title", "description"],
minCharacters: 0,
onSelect: this.selectEntry,
});
js/browser/catalogueSelect.js:123:11 - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type '{
name: string; namespace:
string;
type: string;
source: { category: any; title: any; id: any; description: any; }[];
fullTextSearch: string;
maxResults: number;
searchFields: string[];
minCharacters: number;
onSelect: (result: any, response: any) => void;
}'
is not assignable to parameter of type 'Param'.
Object literal may only specify known properties, and 'fullTextSearch' does not exist in type 'Param'.
123 fullTextSearch: "exact",
node_modules/@types/semantic-ui-search/global.d.ts:100:9
100 (settings?: SearchSettings): JQuery;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The last overload is declared here.
文档
根据
Semantic UI Search documentation
:
将搜索设置为“精确搜索”
匹配字符串中的某个位置,设置为false将只匹配到
字符串开头。(此设置以前称为searchFullText。)
细节
-
TypeScript 3.7.5版
-
带有JSDoc注释的JavaScript代码,通过
tsc --noEmit
-
包.json包括
"@types/semantic-ui": "^2.2.7"
P、 S:我误解了错误消息,似乎“parameter of type”描述的是实际输入,而不是预期的输入,global.d.ts文件包含旧的参数名“searchFullText”而不是新的“fullTextSearch”。