Tailoring optical properties of 2D semiconductors in van der Waals heterostructures