Preheat Oven: Preheat your oven to 400°F (200°C). Line two baking sheets with parchment paper.
Bake Puff Pastry: Place each sheet of puff pastry on a prepared baking sheet. Use a fork to prick the pastry all over to prevent it from puffing up too much during baking. Bake for 15-20 minutes or until golden brown and crisp. Remove from the oven and allow to cool completely.
Step 2: Prepare the Custard Filling
Heat Milk: In a large saucepan, heat the whole milk over medium heat until it begins to simmer. Do not let it boil.
Mix Dry Ingredients: In a large mixing bowl, whisk together the granulated sugar and all-purpose flour.
Add Egg Yolks: Add the egg yolks to the sugar and flour mixture, whisking until smooth and well combined.
Temper Eggs: Gradually whisk the hot milk into the egg mixture, a little at a time, to temper the eggs and prevent them from curdling.
Cook Custard: Return the mixture to the saucepan and cook over medium heat, stirring constantly, until the mixture thickens and comes to a boil. Continue to cook for 1-2 minutes, then remove from heat.
Add Flavorings: Stir in the vanilla extract and rum (if using). Transfer the custard to a large bowl, cover with plastic wrap directly on the surface to prevent a skin from forming, and let it cool completely.