I have the
enum EthereumNetwork {
MAIN_NET,
ROPSTEN,
KOVAN
}
class EthereumHDWallet {
constructor(network: EthereumNetwork) { }
}
The task is to write a test which goes over all possible networks and trying to create EthereumHDWallet. Something like that:
for (const network in EthereumNetwork) {
const wallet = new EthereumHDWallet(network);
it('constructor', () => {
expect(wallet).toBeDefined();
});
}
Unfortunately, the code above doesn't work because of error TS2345: Argument of type 'string' is not assignable to parameter of type 'EthereumNetwork'. Does anyone know way around?
enums in TypeScript boil down to both the numeric index and the string representation. That's what you're seeing in the examples you've provided.