Creatures such as the Deva, Couatl and Oni have an ability which lets them magically polymorph into a humanoid, stating that they keep their statistics (other than ones listed as changing). Does this mean they keep their type (Celestial or Giant, in the above examples), and as such would not be affected by spells such as Charm/Hold Person or Crown of Madness (which specifically list Humanoids as their targets), or would their type become Humanoid for the duration of the transformation, and therefore they would be affected by these spells?
Almost all shapechangers leave type unchanged. Metallic dragons, though, do change their type.
"Statistic," as a defined term, is spelled out on MM pp.6-11. The second element spelled out is "Type," of which both Celestial/Giant and Humanoid are instances. So which stays?
The Coautl's and Deva's change shape abilities specify that they retain their statistics except for a few callouts which do not include type. Since their Celestial type is a statistic they retain it and are still Celestial while in humanoid form.
The Oni's change shape ability specifies that the only statistic to change is size. Since type does not change, the Oni is still Giant while in humanoid form.
For completeness, the Quasit, Yochlol, Imp, Doppelganger, various weres, Mimic, Slaadi, Incubus/Succubus, Vampire, and various Yuan-ti are the other shapechangers in the MM. The Night Hag and Lizardfolk Shaman also change shape (ability) without being shapechangers (tag). All shapechange with similar verbiage to one of the samples above and so all retain their type.
Metallic Dragons' Change Shape ability does change type, as spelled out in their ability description.
Answer: The ability will tell you whether or not the statistics of the shape replace your own. At that point anything that affects a specific type will be determined by the creature's new type (if it changed).
I will provide two creature types below from the Monster Manual that draw upon the RAW information on Type: MM pg. 6 includes Type as a statistic.
Number 1: Change Shape while retaining statistics.
A monster such as Deva (MM pg. 16 - emphasis mine) has the ability Change Shape. This ability explicitly states that:
In a new form, the deva retains its game statistics and ability to speak, but its AC, movement modes, Strength, Dexterity, and special senses are replaced by those of the new form, and it gains any statistics and capabilities (except class features, legendary actions, and lair actions) that the new form has but that it lacks.
This very clearly outlines that a Deva retains it's type.
Number 2: Change Shape with a change in statistics.
A Bronze Dragon (MM pg.107 - emphasis mine) does not retain it's type.
Change Shape. The dragon magically polymorphs into a humanoid or beast that has a challenge rating no higher than its own, or back into its true form. It reverts to its true form if it dies. Any equipment it is wearing or carrying is absorbed or borne by the new form (the dragon's choice). In a new form , the dragon retains its alignment, hit points, Hit Dice, ability to speak, proficiencies, Legendary Resistance, lair actions, and Intelligence, Wisdom, and Charisma scores, as well as this action. Its statistics and capabilities are otherwise replaced by those of the new form, except any class features or legendary actions of that form.
The following alteration spells include wording that highlights the statistic swap that occurs when they are cast:
Shapechange (PHB pg. 275-276)
Your game statistics are replaced by the statistics of the chosen creature, though you retain your alignment and Intelligence, Wisdom, and Charisma scores.
Polymorph (PHB pg. 266):
The target’s game statistics, including mental ability scores, are replaced by the statistics of the chosen beast. It retains its alignment and personality.
True Polymorph (PHB pg. 283)
The target’s game statistics, including mental ability scores, are replaced by the statistics of the new form. It retains its alignment and personality.