Im updating my project from Javascript to Typescript. Up until now I had no issues using revertedWithCustomError
. When trying to assert with revertedWithCustomError
I get the following linter error messaged Property 'revertedWithCustomError' does not exist on type 'Assertion'.
I saw a similar issue in this post which says to use hardhat-toolbox, install it and import it which I have done.
The header imports in my TS look like:
const ethers = require("ethers");
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
import { expect } from "chai";
import { BigNumber, constants } from "ethers";
Here is my tsconfig.json file:
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"exclude": ["dist", "node_modules"],
"include": ["./src", "./scripts"],
"files": ["./hardhat.config.ts"]
}
Here is an example test snippet:
it("Should validate list errors 721", async function () {
const { Marketplace, New1155Nft, New721Nft } = await loadFixture(deployFixture);
await expect(marketplace.connect(USER).listNFT(
marketplace.address,
BigNumber.from(1),
ethers.utils.parseEther("1"),
TOMORROW, IN_FIVE_DAYS,
{ value: listingFee}
)).to.be.revertedWithCustomError(marketplace, "UnsupportedNftInterface");
});
How do I resolve the error?