In a saucepan bring milk, vanilla, and salt to a simmer over medium heat. Do not boil the milk as it can overflow the pan and also overcook the eggs when tempering.
In a separate bowl, whisk together the egg yolks, sugar, cornstarch. It should be thick, creamy, and pale yellow.
While whisking, slowly add ½ cup of the hot milk mixture to the egg yolk mixture to temper it. This insures that the eggs don’t overcook and curdle.
Add the remaining milk mixture half a cup at a time, while continuously mixing.
Return to saucepan and cook over medium low to medium heat until the mixture is thick and bubbling. Remove from heat once the mixture boils.
If adding butter, add one tablespoon at a time and mix until fully incorporated before adding the next. Sometimes the butter separates a bit and makes the mixture greasy. If this happens, whisk continuously for a few minutes until it’s fully combined and cooled down a bit. It should recombine and no longer be greasy.
Once everything is fully combined and slightly cooled but still warm, pour the mixture through a fine mesh strainer into another bowl. This will make for a very smooth pastry cream.
Cover with plastic wrap, placing the wrap directly on top of the pastry cream filing so it doesn’t get a film on top.
Then chill until ready to use, at least two hours or overnight.