Terahertz emission spectroscopy (TES) has recently played an important role in unveiling the spin dynamics at a terahertz (THz) frequency range. So far, ferromagnetic (FM)/nonmagnetic (NM) heterostructures have been intensively studied as THz sources. Compensated magnets such as a ferrimagnet (FIM) and antiferromagnet (AFM) are other types of magnetic materials with interesting spin dynamics. In this work, we study TES from compensated magnetic heterostructures including CoGd FIM alloy or IrMn AFM layers. Systematic measurements on composition and temperature dependences of THz emission from CoGd/Pt bilayer structures are conducted. It is found that the emitted THz field is determined by the net spin polarization of the laser induced spin current rather than the net magnetization. The temperature robustness of the FIM based THz emitter is also demonstrated. On the other hand, an AFM plays a different role in THz emission. The IrMn/Pt bilayer shows negligible THz signals, whereas Co/IrMn induces sizable THz outputs, indicating that IrMn is not a good spin current generator, but a good detector. Our results not only suggest that a compensated magnet can be utilized for robust THz emission, but also provide a new approach to study the magnetization dynamics especially near the magnetization compensation point.