Composer alias vs composer replace for downgrading/removing drush

I was wrestling with composer yesterday to try to get Drush 10 out of a project where I wasn’t ready for it (because while Aegir is amazing, drush 9+ support is still a WIP).

My first instinct was to use “alias”:

composer require drush/drush:"8.4.6 as 10.3.6" --update-with-all-dependencies

That worked, but I don’t actually need drush to be installed in my prod encironment at all, but it is in require in a dependency. That’s when Andrii told me about “replace”:

    "replace": {
        "drush/drush": "^10"
    },

In… a fun loophole/feature, if you use replace but don’t specify a replacement, it acts like ignore.

🤯🎉