SDSS-IV MaNGA : spatially resolved star formation histories in galaxies as a function of galaxy mass and type