TypeChain icon indicating copy to clipboard operation
TypeChain copied to clipboard

Preserve inheritance

Open wbt opened this issue 3 years ago • 3 comments

With contract code like contract Car is GroundVehicle and contract Truck is GroundVehicle I get types generated for CarInstance and TruckInstance and GroundVehicleInstance but when I have a function expecting a GroundVehicleInstance I can't pass in the CarInstance without a type error. This is because the types returned by a given function are incompatible: Type 'import("path/to/Car").AllEvents' is not assignable to type 'import("path/to/GroundVehicle").AllEvents'. Those incompatible types are the generic parameter to the Promise<Truffle.TransactionResponse<HERE>> type used in responses to functions.

This code would be much more useful if the inheritance could be preserved and used in that way.

wbt avatar May 03 '22 00:05 wbt

Good point. This works fine with the ethers-v5 target but as long I can tell you are referring to the truffle target, right?

krzkaczor avatar May 15 '22 13:05 krzkaczor

Yes, I am.

wbt avatar May 16 '22 15:05 wbt

@krzkaczor I'm seeing inheritance chains being lost with the ethers-v5 target, the classes are being flattened down. Have there been any changes to the default behavior there recently?

jmrossy avatar Jun 14 '22 20:06 jmrossy