I start by peeling and cubing the sweet potatoes into roughly one-inch pieces so they cook evenly. I drop them into a large pot of water and bring it to a boil over high heat. Once they're fork-tender, which takes about 15 to 20 minutes, I drain them well so excess water doesn't water down my filling.
While the potatoes are still warm, I mash them with a potato masher or hand mixer until smooth. Then I stir in the melted butter, milk, sugar, eggs, vanilla, and salt until everything is fully combined. I taste the mixture here and adjust the sweetness if needed before moving on.
I pour the sweet potato mixture into a greased 9×13-inch baking dish and smooth the top with a spatula. Getting an even layer here means the casserole bakes consistently and looks neat once it's out of the oven. This is also when I preheat my oven to 350°F.
In a separate bowl, I combine the chopped pecans, brown sugar, flour, melted butter, and cinnamon if I'm using it. I mix with a fork or my fingers until it forms small, crumbly clusters rather than a paste. This simple topping for sweet potato casserole is honestly my favorite part of the whole dish.
I evenly scatter the pecan topping over the sweet potato filling, covering it from edge to edge. The dish goes into the preheated oven for about 45 minutes, until the top turns golden brown and the edges look slightly set and bubbly.
Once it's out of the oven, I let the casserole rest for about 10 minutes before serving. This short rest helps the filling firm up just enough to hold its shape when scooped, so you're not left with a runny spoonful.