Technically yes and no.
The phone ignores USB peripherals/data transfer by default unless you enable them meaning you have to enable data transfer explicitly.
But it isn't foolproof, the risk still exists and you'd be a fool to assume anything is 100℅ secure. Although personally I'd feel much more confident using GOS than stock android in this setting.
The safest solution I've found is to use a data blocker with a clear/transparent cover, which physically isolates the cables data ports.
This gives me the physical piece of mind that I'm looking for- if I'm ever going to risk public charging, it means the host I'm charging can't even see that j have a pixel. If you don't use a USB blocker no data is transfered by default, but whatever you plug in to can still see your device. Try this on your home PC.
If anybody wants to correct me or give the technical insight I can not then please do.