If the condition/effects imposed by a spell is only valid for a given creature type, the spell effect says so. This is often different (and more general) than the targeting requirement.
This has been clarified in a recent Sage Advice Q&A:
Does Charm Person ends if polymorph is
cast on the charmed humanoid, changing its type to beast?
Mike Mearls: nope, restriction applies to targeting -
sticks after successful cast #wotcstaff
Spell descriptions state the conditions that will end the spell, and changing form to another type is typically not one of the conditions.
Targeting and Conditions can (often do) have different type requirements
Consider the description of the Dominate Person. (PH 235) It states “You attempt to beguile a humanoid” but then the subsequent effects of the spell refer to the target as “the creature.”
Once the target is under the influence of the spell, they are dominated as long a they remain a creature (and no other condition occurs that would explicitly end the spell).
Beast spells typically do end when the target changes type
Contrast this with the effect of the spell Dominate Beast — its spell effect refers to the target as “beast” throughout: not just “You attempt to beguile a beast” but then continuing “while the beast is charmed.” In this case, the spell effect designates the charmed condition, not just the target, relies upon the creature type being a beast.
Charming spells in the PH that target beasts (e.g., Animal Friendship, Dominate Beast) consistently refer to the target as “the beast” in the spell effect, while spells that target humanoids (e.g., Charm Person, Dominate Person) refer to the target as “humanoid” only during the targeting, and then refer to the target as “the creature” and/or “that target.”
Mearls tweet is a clarification, not a contradiction, of Crawford’s
There is no contradiction between Mearls’ tweet that Charm Person would persist, and Crawford’s tweet the Dominate Beast would not. Dominate Beast works “while the beast is charmed” (PH 235) and Charm Person affects “the charmed creature.” (PH 221)
For any specific spell, simply check whether the wording of the spell effect changes from the specific creature type to “creature” when it transitions from discussing targeting to delineating the effects and condition imposed, to see if the condition can be dodged by changing your creature type.