NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7k stars 1.36k forks source link

defaultValue of variadic parameters should allow empty arrays #5391

Open schaable opened 3 weeks ago

schaable commented 3 weeks ago

There's a bug in the current task builder validations where trying to set the default value of a variadic parameter to an empty array throws an error.

const testTask = task("test", "Runs mocha tests")
  .addVariadicParameter({
    name: "testFiles",
    description: "An optional list of files to test",
    defaultValue: [], // this fails, but it shouldn't
  })

The bug is here: parameters.ts line 39.

Removing value.length > 0 should be enough to fix it. Make sure to update the tests to ensure it works as expected.