An extension of the time-dependent Takagi-Taupin theory to 'optical phonon'-type distortions is presented. By splitting the susceptibility into the contributions from each atom in a unit cell, modifications to the structure factor as well as lattice parameter are taken into account. The result is a compact, surprisingly simple, equation with a strong formal similarity to the classical Takagi-Taupin equation, with the latter included as a special case. Time dependence is explicitly retained and thus the analysis is applicable to situations where the crystal is modified on time scales comparable with that for the X-rays to traverse an extinction depth. A comparison is made between the influence of coherent acoustic and optical phonons on the diffraction of X-rays. Numerical and perturbative analytical solutions of the generalized Takagi-Taupin equation are presented in the presence of such phonons.