I'd like to keep a flashlight by my bed for home safety. I intend to only use it in emergencies. Since it's for a home safety emergency, I want to keep the battery stored in the flashlight so it's immediately usable. The flashlight I have is designed to take a 18650 battery or three AAA cells. To avoid battery corrosion and keep my flashlight functional in an emergency at least for a short time, what is the best type of battery to use in this situation? Lithium-ion? Non-rechargeable lithium? Alkaline? Nickel metal hydride? For how long is it safe to store that kind of battery in the flashlight?
Don't use any sort of rechargeable cells. They will be flat through self-discharge by the time you use them.
Non-rechargeable lithium cells aren't common in the size you want, but if you can source some, then they will last many years.
Otherwise, get brand new alkaline cells from a reputable manufacturer. Check the "install by" date on the betteries or the packaging, to make sure they have several years left on them. Even after their "install by" date, they will still work for a few more years, but will no longer last as long when you do use them.