The compression does not have this effect, in general.
You should be more specific in your questions.
Adiabatic compression, for example, happens without any heat exchange between the gas and the environment. The gas just heats up.
You may have in mind isothermal compression.
In this case, in order to ensure the constant temperature condition, the gas needs to be in contact with an external reservoir which will absorb whatever heat is necessary to keep the temperature constant.
If the gas does not give up heat to exterior then it cannot be iso-thermal. It will be adiabatic.
So the heat exchange situation depends on the external conditions, not on the compression itself. .