我是Next.js和TypScript的新手,似乎找不到任何有关如何解决此问题的资源:
import Image from 'next/image';
export default function Item({ image }) { // <-- parameter image needs a 'type' definition?
...
}
但上面给出了有关参数image
的通知/警告/错误:
Binding element 'image' implicitly has an 'any' type.ts(7031). (parameter) image: any
示例使用image
:
<Image src={image} alt={title} fill />
我知道TS需要定义/声明变量类型,但我肯定不知道NextJS Image应该是什么"类型",而且我也知道给它any
类型也不是正确的 Select ?如何解决此问题?
我try 了以下操作,但不起作用:
export default function Item({ image: Image }) { // <-- tried the `image: Image` syntax
是否有人有任何资源、文档或首选位置来搜索参数/函数的正确类型以及与之相关的正确语法来平息这些警告?
提前感谢.