If you want to work at a smaller company or found a startup, being a generalist is a great asset. It also puts you closer to the top of the hierarchy if you can make yourself invaluable to the business/yourself by being a “Swiss army knife.” By that, I mean everyone wants you around, because you can probably solve upwards of 90% of the problems that arise.
Of course, you can’t be a full generalist, you will end up having some language or tech stack you’re more adept in. That’s fine. You’ll probably end up being “T” shaped.
But to reiterate: if you want to make good money and you love a niche topic, specialize in it. Then go and work at a company with the scale/needs for that specific niche. Otherwise, if you’re a generalist, you’re better equipped to handle a vast multitude of problems, build initial solutions, and then hand them off to specialists as your company/project grows.
Edit: You might also just be a fox and not a hedgehog — that’s what I would consider myself. An interesting read: https://en.m.wikipedia.org/wiki/The_Hedgehog_and_the_Fox.