Preheat the oven to 350°F (175°C).
Lightly grease a 9x13-inch baking dish or similar casserole dish.
Place the sweet potato chunks in a large pot and cover with cold water by 1 inch. Add a pinch of salt. Bring to a boil, then simmer until very tender, about 15–20 minutes.
Drain well and let the potatoes sit in the hot pot for 2 minutes to steam off excess moisture.
This step helps keep the casserole from turning watery.
Mash the sweet potatoes until smooth. Stir in butter, maple syrup, milk, vanilla, cinnamon, nutmeg, and salt. Taste and adjust sweetness or salt.
If using, whisk in the beaten egg once the mixture has cooled slightly.
Spread the sweet potato mixture evenly in the prepared baking dish, smoothing the top with a spatula.
Make the topping: In a medium bowl, combine pecans, oats, brown sugar, flour, cinnamon, and salt. Pour in melted butter and maple syrup. Stir until clumps form.
Scatter the pecan mixture evenly over the sweet potatoes.
Don’t pack it down—loose crumbs get crispier.
Bake uncovered for 28–35 minutes, until the topping is golden and the edges are slightly bubbling.
Let the casserole rest for 10 minutes before serving. For a finishing touch, sprinkle with a pinch of flaky salt and offer extra warm maple syrup on the side.