By Fourier theory, any complex waveform can be decomposed into a (possibly infinite) sum of sinusoids, each with its own amplitude, frequency, and phase parameters.
In general, waveforms with time-domain discontinuities require an infinite number of sinusoids to be perfectly reconstructed.
In digital audio contexts, however, we are only interested in keeping sinusoidal components that have frequencies up to half the sample rate.
A square wave and its associated magnitude spectrum are shown in Fig. 1 below.
Figure 1:
One period of a square wave and its associated frequency magnitude response.
A sawtooth wave and its associated magnitude spectrum are shown in Fig. 2 below.
Figure 2:
One period of a sawtooth wave and its associated frequency magnitude response.
A triangular wave and its associated magnitude spectrum are shown in Fig. 3 below.
Figure 3:
One period of a triangular wave and its associated frequency magnitude response.