Bartali rode until he was 40, and won a Tour at 34, winning seven stages along the way. He podiumed Giri until he was almost 36. Coppi won his last Giro at 33 (going on 34), and another the previous year. Both his tours came beyond the age of twentynine - his GC skills remained long, but it was his one day races which got worse. Bobet won his at the traditional 'peak' years, and Anquetil won everything before he was 31. Gimondi won a Giro at 34 as well, but Big Mig, Hinault and Merckx lost everything by the time they turned 31 or 32.
Basically, it differs a lot between person to person. Some lose it over 30, some keep it, some thrive. It isn't unheard of for older riders to do well, but it is rare. However, it cannot be put solely down to doping, but also physiology.