浏览器窗口中的虚假 TypeScript 错误

huangapple go评论52阅读模式
英文:

False typescript errors in the browser window

问题

label参数在截图中明显显示为字符串类型。然而,在编译代码后,浏览器窗口中出现了一个错误,指出label具有any类型。请告诉我是什么原因以及如何修复这个问题。

英文:

I have a line of code written using Typescript. The label argument has a string type this is clearly visible in the screenshot
浏览器窗口中的虚假 TypeScript 错误

At the same time, after compiling the code, an error appears in the browser window that says that label has the type any.

浏览器窗口中的虚假 TypeScript 错误

Please tell me what is the cause and how can I fix this behavior

答案1

得分: 1

指定标签为字符串类型

mdValue = filterData.value.map((label: string) => {
 // ...
});
英文:

Specify the label to be of type string

mdValue = filterData.value.map((label: string) => {
 // ...
});

huangapple
  • 本文由 发表于 2023年2月8日 18:08:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75384187.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定