Exchange control of target artifact or creature and another target permanent that shares one of those types with it. (This effect lasts indefinitely.)
You can’t cast Legerdemain unless both targets share a type at that time. It will also check to make sure they share a type as it resolves. If they no longer do so, the exchange will not occur.