Currently, I have a function running that imports ethers from the "ethers" library.
import { ethers } from "ethers";
async function requestAccount() {
await window.ethereum.request({ method: "eth_requestAccounts" });
}
The problem arises when using typescript as it shows an error message:
Property 'ethereum' does not exist on type 'Window & typeof globalThis'
To resolve this issue, I made the following adjustment:
declare global {
interface Window{
ethereum?:any
}
}
However, I feel like this may not be the most efficient way to utilize typescript. How can I modify this so that the interface value is accurate? My understanding is that it should be an object with a method inside, but I am unsure of the correct syntax in typescript.
Any assistance would be greatly valued.
Thank you