Environmental engineering of transition metal dichalcogenide optoelectronics