Most (if not all) companions have a default weapon they use if not given a weapon. For Piper, it's a 10mm pistol. For Danse, it's a laser rifle, etc. In the case of their standard weapons, they do not have to be supplied ammo.
But for some reason, late into the game, when they do not have a weapon I gave them, they began to use their fists. They might use a melee weapon they find, but ultimately refuse to pick up guns and use them. (Needless to say, it's not particularly easy to fight enemies when your companion is crowding around them). I can simply give them weapons to use, but that still requires that I give them ammo. (which they run through very quickly.) Still, not a massive problem.
The only big problem is some NPCs are the same way. Minutemen, Raiders, Synths, ironically even Gunners are using their fists much more often than the guns they clearly had. You would expect it to be due to proximity; get close, they default to melee. But that's not the case. They will fire a couple of shots before switching to melee, running at their target (which is quite a fair distance away), to practically get into a fist-fight.