Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type annotation for hre object being passed to Javascript deployment scripts #507

Open
daniel-mccloud opened this issue Dec 20, 2023 · 0 comments

Comments

@daniel-mccloud
Copy link

Is your feature request related to a problem? Please describe.
Vs code is able to read and apply type annotations so that interacting with the hre object becomes more fluid in Javascript language

Describe the solution you'd like
I would like to have the same autocompletion and Intellisense functionality as shown in the picture:
image

For example say you have a bunch of deployment scripts following the pattern:

module.exports = async ({ getNamedAccounts, deployments, network }) => {
  const args = []

  const { deploy } = deployments
  const { deployer } = await getNamedAccounts()
  await deploy('Alpha', {
    from: deployer,
    args,
    log: true
  })
}
module.exports.tags = ['Alpha']

Currently a developer would have to edit it to:

/**
 * @param {import('hardhat/types').HardhatRuntimeEnvironment} hre - Hardhat Runtime Environment
 */
module.exports = async ({ getNamedAccounts, deployments, network }) => {
  const args = []

  const { deploy } = deployments
  const { deployer } = await getNamedAccounts()
  await deploy('Alpha', {
    from: deployer,
    args,
    log: true
  })
}
module.exports.tags = ['Alpha']

But not all developers will be doing that because maybe they are not aware of this possibility or for any other reason will not do it.
So ideally the type annotation should be applied on hardhat-deploy in a way there would be no need to add the type annotations here.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
It would be also nice to have the ability to process .mjs and .cjs deployment scripts in deploy folder. Or to make the entire package modular with "type": "module" in package.json to process esm code in .js files within deploy folder just like node does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant