Yeah I agree. There are actually two issues here:
- Not all ports support the tx/rx pins being set. (e.g. STM32)
- Some ports (e.g. esp8266) take a machine.Pin while others (e.g. esp32 like you say) take a pin number.
I'd guess this was just an oversight in the ESP32 port... there's probably no reason why it couldn't accept both integers and objects. Are you interested in sending a PR to fix this? Or at least raise a bug?
I imagine this will get addressed eventually when some more work is done standardising the various machine objects. (See recent work on ADC).