Improve typings for contracts
See original GitHub issueHey Richard!
I am the maintainer of TypeChain and I would like to forward some ideas that would greatly improve our generated types. I am more than happy to make PRs to fix this - I just want to discuss these ideas first here.
- TypeChain generated contracts extend
packages/contracts/src.ts/index.ts/Contractclass. The problem is that this class has index signatures for functions which we can’t override in any way.
Example:
readonly functions: { [ name: string ]: ContractFunction };
Despite the fact that we generate exact typings for all contract methods it’s possible to mistype a method name and use a generic ContractFunction. This should result in a type error. I would propose extracting BaseContract interface without any index signatures so both ethers’s Contract and TypeChain generated types can extend that.
Related to: https://github.com/ethereum-ts/TypeChain/issues/276 and https://github.com/ethereum-ts/TypeChain/issues/351
- We realized that
packages/contracts/src.ts/index.ts/Overridesis missing{ from?: string | Promise<string> }. I would like to add it.
Related to: https://github.com/ethereum-ts/TypeChain/pull/345
WDYT? As I mentioned already I can prepare PR if you approve these changes.
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (8 by maintainers)

Top Related StackOverflow Question
This is now in 5.1.0. Try it out and let me know how it goes. 😃
@ricmoo closing this now. The problem that I described above was caused by ethers version mismatch. Thanks! Ethers & TypeChain work great together now!