Preheat your oven to 350°F (175°C) and grease a baking dish. A 9x9 inch (23x23 cm) dish should work well for this recipe.
Peel the sweet potatoes and cut them into even sized pieces, then place them in a large pot. Cover them with water and bring to boil.
Cook the sweet potatoes for about 15-20 minutes, or until they are fork-tender. Drain and let them cool for a few minutes.
While the sweet potatoes are cooking, you can prepare the topping. In a small bowl, rub the butter and flour together with your hands until you get a crumbly but chunky consistency.
Mix in the sugar and pecans and set aside.
Place the cooked sweet potatoes in a large mixing bowl. Mash them using a potato masher or a fork until they are smooth.
In a separate bowl, beat the egg, then add the sugar, milk, salt, and vanilla extract. Mix well to combine.
Pour the egg mixture into the mashed sweet potatoes and stir until everything is thoroughly combined.
Transfer the sweet potato mixture to the prepared baking dish and spread it evenly.
Sprinkle the topping over the sweet potato mixture.
Cover with foil and bake in the preheated oven for about 15-20 minutes. Then remove the foil and bake for another 20 minutes until the casserole is heated through, and the pecans are lightly toasted.
Remove the casserole from the oven and let it cool for a few minutes before serving.