Because of a special mechanic with Roost. Basically, when a Pokemon uses Roost, if it has the Flying type, it loses its Flying type for that turn. It will regain its Flying type once the turn ends.
Since he lost his Flying type, you were able to hit Aerodactyl with Dig.