If you want to see a country that has been old before it truly became rich, just take a look at Thailand.
They are a large country with a below replacement TFR for decades, a high median age, and a relatively low median household income ($7k/yr) yet they have not collapsed.
Most of this is because of social welfare - most high revenue industries are very highly skilled and this require a small skilled or semi-skilled workforce.
Think industries like Automotive, Semiconductors, ONG Refining, Finance, etc - this is the Thai economy (tourism is actually a relatively small portion compared to those).
Deploying tax money generated from those industries into social welfare such as expanded healthcare, expanded social services, etc helps minimize a lot of the issues at hand.
China has been concentrating on building some form of a social safety net as well in a manner similar to TH, but it's at an earlier stage, but tbf, TH hit the same issues China did today in the early 2000s.