将 monaco-editor 从 0.24 升级到 0.41 之后,下面的 typescript 编译失败
return {
suggestions: variables.map(v => ({
label: { name: v, type: labelTypeDict[v] },
kind: monaco.languages.CompletionItemKind.Variable,
insertText: buildText(v),
detail: detailDict[v],
range,
})),
};
错误如下
Type '{ label: { name: "author" | "post_url"; type: string; }; kind: CompletionItemKind.Variable; insertText: string; detail: string; range: { startLineNumber: number; endLineNumber: number; startColumn: number; endColumn: number; }; }[]' is not assignable to type 'CompletionItem[]'
请问如何解决这个问题?
把 name
改为 label
就可以了
label: { label: v, type: labelTypeDict[v] }