A PS5 can technically be used to charge a Switch, but you still may want to avoid trying it yourself.
Reddit user adhaas85 discovered that they were able to create an unholy fusion of Sony and Nintendo electrical current by running a USB-C cable from the front of their PS5 (which has one type-C "Superspeed" port and one standard type-A port on the front) to the back of their Nintendo Switch dock. The Switch dock can then be used to charge the Switch as normal - and though adhaas85 didn't mention trying it, I can't think of any reason you couldn't play on your TV with this setup too - it'd just be another HDMI cable adding to the strange wire spaghetti this creation already necessitates.
Now, this may in fact be the closest we've come to a Nintendo PlayStation since the two companies broke off their console collaboration plans in the early '90s, but you probably shouldn't try to recreate it with your own setup out of an abundance of caution. Nintendo Switch is notoriously picky with what kind of USB-C power supply it will work with, and early in the console's lifecycle it wasn't uncommon to hear about third-party docks and chargers bricking Switch systems because of incompatible specs.
You really would hope that the USB standards would keep everything easy and compatible, but you're always going to be safest with an official solution - check out our guide to best Nintendo Switch chargers for more info. Hopefully this won't be as big of a concern with future consoles, especially now that USB-C is much more common than it was in 2017.
Speaking of future consoles, the Nintendo Switch OLED model was announced just yesterday, and Nintendo Switch OLED pre-orders have already opened at some retailers. It features a bigger, more vibrant screen and an improved stand - and the dock is getting some improvements as well, including built-in ethernet for wired internet.