我是 Next.js 和 TypeScript 的新手,似乎找不到任何有关如何解决此问题的资源:
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
我知道 TS 需要定义/声明变量类型,但我确实不知道 NextJS Image 应该是什么“类型”,而且我也知道给它
any
类型也不是可行的方法?我该如何解决这个问题?
我尝试了以下方法但不起作用:
export default function MealItem({ image: Image }) { // <-- tried the `image: Image` syntax
是否有人有任何资源、文档或首选位置来搜索参数/函数的正确类型以及与之相伴的正确语法来消除这些警告?
提前致谢。