I've had this happen to two XS phones now. In the first case, my phone occasionally would power itself off and then come back on of its own accord in 10-15 minutes or so. It won't power on no matter what I did. I took it to Apple twice who found no hardware fault, but shortly after leaving the store on the second visit it happened again so I went back and they couldn't get it to power on so replaced it.
The replacement phone started acting up over the last two weeks. It would drop phone calls (not call failed) and occasionally I'd come back to use it and it had obviously restarted - the phone would be asking for my passcode having been in a case with the front flap down. I took it to Apple last week who ran tests and came back with no fault found, so told me it was a carrier issue (which it clearly wasn't) but they weren't prepared to do anything.
Yesterday morning, phone was fully charged, switched itself off at half past nine in the morning and wouldn't come back on. Got to Apple last night who were really good in seeing me without an appointment. As like the first time they replaced the phone, they couldn't resurrect it or get any info out of it at all, so I'm now on my 3rd iPhone XS.
Apple claim they've not heard of this issue before, but the really frustrating thing is that unless the phone is actually DOA when they see it, it seems to pass their tests, so you may get short shrift. The first phone exhibited signs it was on its way out, but would usually recover whereas the second one never exhibited the problem until the first time it happened and wouldn't recover from it.
The phones have never been jailbroken, never had betas running on them and I've tried restoring both as backups and as fresh new phones when the issues started happening. I only use official apple charging cables, so I'm at a loss as to why I've had two of these die on me.
I did ask if I could swap the XS for another model but that wasn't possible as the repair system only gives them a scripted option and they weren't willing to speak to a manager, so fingers crossed for third time lucky.