Describe the bug
Hardhat Deploy generates a deployment that does not match the Deployment type.
Receipt has string or undefined type for to property, but plugin generates null.
This cause error when assign imported deployment JSON to variable of Deployment type:
ERROR in src/contracts/greeter.ts:8:7
TS2322: Type '{ address: string; abi: ({ inputs: { internalType: string; name: string; type: string; }[]; stateMutability: string; type: string; name?: undefined; outputs?: undefined; } | { inputs: never[]; name: string; outputs: { ...; }[]; stateMutability: string; type: string; } | { ...; })[]; ... 10 more ...; storageLayout: {...' is not assignable to type 'Deployment'.
The types of 'receipt.to' are incompatible between these types.
Type 'null' is not assignable to type 'string | undefined'.
6 |
7 | import greeterDeploymentJson from '../hardhat/deployments/current/Greeter.json';
> 8 | const greeterDeployment: Deployment = greeterDeploymentJson;
| ^^^^^^^^^^^^^^^^^
To Reproduce
Steps to reproduce the behavior:
Prepare basic scaffold:
yarn add --dev hardhat
yarn exec hardhat # Create an advanced sample project that uses TypeScript
yarn add --dev hardhat-deploy @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers
# and so on...
Describe the bug Hardhat Deploy generates a deployment that does not match the
Deployment
type.Receipt
hasstring
orundefined
type forto
property, but plugin generatesnull
. This cause error when assign imported deployment JSON to variable ofDeployment
type:To Reproduce Steps to reproduce the behavior:
yarn hardhat deploy
Greeter.json
and see:Expected behavior If there are no
receipt.to
do not generate this property at all.versions