I'm using @nomicfoundation/hardhat-toolbox
v3.0.0 that uses ethers v6.
The below code works in ethers v5 with @nomicfoundation/hardhat-toolbox
v2.0.2
import { FundMe } from "./../../typechain-types"
describe("FundMe", async () => {
let fundMe: FundMe
beforeEach(async () => {
const fundMeContract = await deployments.get("FundMe")
fundMe = (await ethers.getContractAt(
fundMeContract.abi,
fundMeContract.address
)) as FundMe
})
})
With the new version, I'm getting the following error:
Conversion of type 'Contract' to type 'FundMe' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Type 'BaseContract & Omit<ContractInterface, keyof BaseContract>' is missing the following properties from type 'FundMe': attach, deployed, functions, MINIMUM_USD, and 9 more.
I've tried:
fundMe = await ethers.getContractAt( fundMeContract.abi, fundMeContract.address )
And getting the error:
Expected 0 type arguments, but got 1.ts(2558)
OR
fundMe = await ethers.getContractAt(
fundMeContract.abi,
fundMeContract.address
)
And I get the error:
Type 'BaseContract & Omit<ContractInterface, keyof BaseContract>' is missing the following properties from type 'FundMe': attach, deployed, functions, MINIMUM_USD, and 9 more
What can I do to make it work with Typescript despite using the any type ?
The code works but VSCode is showing the error.
Same problem. I'm using the workaround for now: