wighawag / hardhat-deploy-ethers

MIT License
69 stars 25 forks source link

Property 'deployments' does not exist on type 'HardhatRuntimeEnvironment'.ts(2339) #18

Closed PatrickAlphaC closed 1 year ago

PatrickAlphaC commented 3 years ago

I have the following code:

/* eslint-disable node/no-missing-import */
// eslint-disable-next-line node/no-unpublished-import
import { HardhatRuntimeEnvironment } from "hardhat/types"
import { DeployFunction } from "hardhat-deploy/types"
import { networkConfig } from "../helper-hardhat-config"

const deployAPIConsumer: DeployFunction = async function (
  hre: HardhatRuntimeEnvironment
) {
  const { deployments, getNamedAccounts, getChainId } = hre
.
.
.

And Im running into the following linting error:

Property 'deployments' does not exist on type 'HardhatRuntimeEnvironment'.ts(2339)

My hardhat.config.ts looks like:

import * as dotenv from "dotenv"

import { HardhatUserConfig, task } from "hardhat/config"
import "@nomiclabs/hardhat-etherscan"
import "@nomiclabs/hardhat-waffle"
import "@typechain/hardhat"
import "hardhat-gas-reporter"
import "solidity-coverage"
import "hardhat-deploy"
import "@appliedblockchain/chainlink-plugins-fund-link"
import "hardhat-deploy-ethers"

dotenv.config()

However, my code runs fine. Is this an error with VSCode or the plugin I'm using?

wighawag commented 3 years ago

Did you follow the installation guide in the readme : https://github.com/wighawag/hardhat-deploy-ethers#installation

some plugin like hardhat-waffle have harcoded dependencies on the plugin @nomiclabs/hardhat-ethers

hardhat-deploy-ethers is a fork of @nomiclabs/hardhat-ethers and so need to be installed as an alias to play nicely with hardhat-waffle

Ideally hardhat-deploy-ethers could extends @nomiclabs/hardhat-ethers and that is the plan but this issue is blocking that feat : https://github.com/nomiclabs/hardhat/issues/1040

PatrickAlphaC commented 3 years ago

Yes.... Might be something with my VSCode... Might try it from scratch to see if maybe I did something funky.

pfives commented 2 years ago

@PatrickAlphaC Hey did you ever figure this out? I'm getting the exact same error

PatrickAlphaC commented 2 years ago

Not sure how I fixed it :/

I ended up redoing everything from scratch and I didn't get the error the second time.

dibakarsutradhar commented 2 years ago

I have recently encountered the same issue in my hardhat project. In my case, the problem was, that I was importing { HardhatUserConfig } from 'hardhat/type' instead of 'hardhat/config' in the hardhat.config file. Changingtype` to 'config' fixed the issue. Hope this helps.

wighawag commented 1 year ago

hardhat-deploy-ethers@next has been released Please, try it out.

It is now an extension to hardhat-ethers so you need both

But note that that new version do not support external artifact if you were using them