Spoiler, the answer is yes: If your battery needs charging, go ahead and charge it overnight while you sleep. The reason it's even a question has to do with outdated battery technologies, old fears solved by modern smartphones and other concerns that this Android Authority video addresses in good order.
The video above tells the tale, but the shorter version here is that fears over your battery having "cyclic memory" or "only a certain number of charges" are holdovers from old nickel-based batteries that most modern devices don't use any more (although some rechargeable batteries do).
As Android Authority explains:
Nickel-based batteries exhibited a tendency to have a cyclic memory. If they weren't given full charges in between cycles, they might "forget" their full capacity and remember the point to which they were last charged as being the maximum capacity. Many of us have never used nickel-based batteries in our mobile devices since the transition to lithium ion had occurred by the early 2000s.
The issue you do have to worry about with lithium-ion batteries however, is their temperature sensitivity. Their charge and output efficacy can vary widely depending on their operating temperature. While most are capable of charging and discharging at normal temperatures, by nature, lithium-ion batteries have no way to handle extra incoming current except by dissipating energy as heat - which means the batteries can get quite hot. This famously caused multiple Samsung Galaxy Note 7 to burst into flames last year, prompting the company to recall and discontinue the product.
Luckily, most modern smartphones address this by cutting off the battery from power once it's charged, and using the incoming current as its primary power source instead, keeping your battery topped off, happy and cool, without the risk of overheating.
As we discussed above, the main danger in leaving your smartphone plugged in overnight was allowing the battery of your device to get hot and remain hot through the rest of the night. However, our mobile devices have gotten much smarter. They can stop charging when the battery has reached its full capacity and begin using the connected charger as its primary power source, allowing you to wake up to a fully-charged battery while your phone remains powered on through the night.
And that's pretty much that. Android Authority goes on to offer some best practices and tips to keep your smartphone battery at peak health in the full article, linked below. You can also hear some of them in the video above, so press play to hear the whole explanation.
On a final note, be sure to only use the charger and cable that came with your smartphone or one from a trusted brand that was purchased in Australia. Most smartphone fires are caused by cheap foreign replacements.