dethcrypto / dethcrypto/TypeChain
Duplicate Struct Import on Factory from Contract
- Dominant language
- TypeScript
- Stars
- 2.8k
- Forks
- 376
- PR merge metrics
- No merged PRs in 30d
Description
After upgrading `@typechain/hardhat` and `ethers-v5` an issue arose: `Duplicate identifier`. This happened for a single struct in one contract, and all contracts inheriting from said contract.
The error occurs with the following `package.json`:
```
"devDependencies": {
"@codechecks/client": "^0.1.11",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@nomiclabs/hardhat-ethers": "^2.0.3",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@solidstate/contracts": "^0.0.29",
"@solidstate/spec": "^0.0.29",
"@typechain/ethers-v5": "^8.0.5",
"@typechain/hardhat": "^3.1.0",
"@types/chai": "^4.3.0",
"@types/fs-extra": "^9.0.12",
"@types/mocha": "^9.0.0",
"@types/node": "^17.0.13",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"chai": "^4.3.4",
"commitizen": "^4.2.4",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0",
"dotenv": "^10.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"esm": "^3.2.25",
"ethereum-waffle": "^3.4.0",
"ethers": "^5.4.6",
"fs-extra": "^10.0.0",
"hardhat": "^2.6.1",
"hardhat-deploy": "^0.10.4",
"hardhat-deploy-ethers": "^0.3.0-beta.13",
"husky": "^7.0.1",
"lint-staged": "^11.1.2",
"mocha": "^9.1.0",
"prettier": "^2.3.2",
"prettier-plugin-solidity": "^1.0.0-beta.17",
"shelljs": "^0.8.4",
"solhint": "^3.3.6",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.16",
"ts-essentials": "^9.1.2",
"ts-generator": "^0.1.1",
"ts-node": "^10.4.0",
"typechain": "^6.1.0",
"typescript": "^4.5.5"
},
```
The error given is:
```
typechain/factories/SomeContractFactory__factory.ts:18:3 - error TS2300: Duplicate identifier 'PayoutsStruct'.
18 PayoutsStruct,
```
`PayoutsStruct` is a custom struct, and is being imported 2x from the auto-generated contract file `SomeContract` .
The command being run is:
`yarn cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain`
The error seems to be created only by the versions of `typechain/ethers-v5` and `typechain/hardhat`. When reverted back to ^7.0.1 and ^2.3.0 respectively, the errors vanish.
Contributor guide
Assessment
This issue has not been assessed yet.