10spd mechs weren’t designed to go beyond a 36T cog. In practice, they can be made to just about work ok on a 40T top cog just by screwing the B-Tension all the way in, but it does compromise the shift quality further down the cassette as a result.
On a 42T cog? You can screw a longer B-Tension screw in and bodge it so that it goes onto the 42T ok, but this screws up the shift quality even more. The only solution that really works is to cough up and buy a One Up Radr cage for the mech, which moves the position of the top jockey wheel so it swings away from the cassette the further up it goes, just like the 11spd mechs.
Personally, I got tired of bodging expensive kit so that it just about works acceptably, and bought 11spd. M8000 XT is only very slightly more expensive than the outgoing M780 stuff and it works brillitantly, no point bodging a 10spd setup when 11 is there at a reasonable price and works so well!