Prepare the sweet potatoes by placing them in a large pot and covering with cold water. Bring to a boil over high heat, then reduce to medium and simmer for 15-20 minutes until the potatoes are fork-tender.
Preheat your oven to 350°F (175°C) and lightly grease a 9×13 baking dish.
Drain the sweet potatoes thoroughly and return them to the hot pot for 1-2 minutes to evaporate excess moisture (this prevents a watery casserole).
Mash the sweet potatoes until smooth. You can use a potato masher for more texture or an electric mixer for ultra-smooth results.
Mix in the wet ingredients – melted butter, milk, beaten eggs, and vanilla – stirring until well combined.
Add the brown sugar, cinnamon, nutmeg, and salt to the potato mixture and stir until everything is evenly incorporated. The mixture should be smooth but still have some body.
Transfer the sweet potato mixture to your prepared baking dish, spreading it into an even layer.
Make the topping by combining flour, brown sugar, salt, and cinnamon in a medium bowl. Cut in the cold butter using a pastry cutter or your fingers until the mixture resembles coarse crumbs.
Stir the chopped pecans into the topping mixture if using.
Sprinkle the topping evenly over the sweet potato mixture, covering the entire surface.
Bake for 25-30 minutes until the topping is golden brown and the casserole is heated through.
Allow to rest for 5-10 minutes before serving to let the flavors settle and make serving easier.