I am running the following function
import { ethers } from "ethers";
async function requestAccount() {
await window.ethereum.request({ method: "eth_requestAccounts" });
}
The issue I am having is I am using typescript and it complains with the following error
Property 'ethereum' does not exist on type 'Window & typeof globalThis'
So I was able to fix it with the following
declare global {
interface Window{
ethereum?:any
}
}
However I don't think this is taking advantage of typescript properly. How would I write it so that the interface value is correct. I assume it should be an object with a method inside, but not sure how to write this in typescript.
Any help would be greatly appreciated.
Thanks
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment