WSe2 has a high mobility of electrons and holes, which is an ideal choice as active channels of electronics in extensive fields. However, carrier-type tunability of WSe2 still has enormous challenges, which are essential to overcome for practical applications. In this work, the direct growth of n-doped few-layer WSe2 is realized via in situ defect engineering. The n-doping of WSe2 is attributed to Se vacancies induced by the H2 flow purged in the cooling process. The electrical measurements based on field effect transistors demonstrate that the carrier type of WSe2 synthesized is successfully transferred from the conventional p-type to the rarely reported n-type. The electron carrier concentration is efficiently modulated by the concentration of H2 during the cooling process. Furthermore, homomaterial inverters and self-powered photodetectors are fabricated based on the doping-type-tunable WSe2. This work reveals a significant way to realize the controllable carrier type of two-dimensional (2D) materials, exhibiting great potential in future 2D electronics engineering.