In terms of life cycle cost, trolleybuses (in particular in-motion charging (IMC) trolleybuses) are by far the cheapest option compared to diesel buses, and in most cases in urban areas compared to overnight or opportunity charging battery buses.
An IMC trolleybus has a small battery, with about 30km of range (it varies depending on specification) that is charged while operating under the wires and runs on battery otherwise. Generally only approximately 50% of the route needs overhead wires for this to work reliably.
The advantage is that the trolleybus does not need to spend long periods at termini charging (as with opportunity charging) or carry around a very heavy battery which reduces passenger capacity (as for overnight charging). They can be rostered in more or less the same way as a diesel bus.
On the electrical side there is much less strain on the grid, as more or less the same number of buses will be under the wires at any given moment, so the current draw from the grid is fairly constant. Opportunity charging requires either large battery/capacitor banks (inefficient) or strains the grid with very short, very sharp peaks. Overnight charging requires a very beefy power supply to the depots and even then the number of buses charging at any one time is generally limited, causing difficulties with rostering.
The trolleybuses themselves are cheaper than any other form of battery bus and fewer of them are needed (because they don't need to stop for charging).
Finally, as far as capacity goes - it is possible to reliably operate bi-articulated buses as IMC buses, but generally not with diesel or pure battery (power to weight ratio issues). These have almost the same capacity as a smaller tram (about 200 people, ignoring covid).
In short, trolleybuses are far from obselete - and have developed significantly since their withdrawal in the UK. I think especially within bigger cities their reintroduction would work wonders, even with relatively small up-front investments (electrify the main corridors where lots of routes intersect and you can electrify very large parts of the system). There's a reason why Berlin is planning to reintroduce trolleybuses from scratch, and Prague has already done so.
The other types have a role to play, but not in urban centres, but rather on smaller, less frequent routes where vehicles travel less far each day or have lots of dwell time at the termini built in.