The carriers interchange, the rear gearsets are the same, the front gearsets are not. Replacement numbers indicate the yj used reverse cut gears in the front axle. This would be consistent with the xj.
My suggestion would be use the carriers from the yj in the tj. The carriers for 4.10 gears and 3.07 gears are different. Get new aftermarket gears for both the front and rear of the tj.You will need new gears in the front anyway and it is very iffy moving gears from one axle to another. Bad tooth contact pattern usually results in broken teeth and it is not worth taking a chance on your primary axle.
Good luck with it