我试图在下一个/打字稿项目中使用以太:
代码:
if (typeof window.ethereum !== 'undefined') {}
错误:
Property 'ethereum' does not exist on type 'Window & typeof globalThis'
我尝试在我的下一个env.d.ts文件中扩展窗口接口,但是错误仍然存在。
next-env.d.ts:
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
declare global {
interface Window {
ethereum: any
}
}
有针对Next.js的特定修复吗?
发布于 2022-09-20 18:45:12
下一个文件不应该被编辑-您可以创建另一个像globals.d.ts
这样的声明文件,其内容如下:
declare global {
interface Window {
ethereum: any
}
}
它应该能起作用
https://ethereum.stackexchange.com/questions/135989
复制相似问题