In a saucepan bring milk, vanilla, and salt to a simmer over medium heat.
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 heat until the mixture is thick and bubbling. 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 if fully combined and slightly cooled, pour the mixture through a strainer into another bowl. This will make for a very smooth pastry cream and ensure there is no cooked egg in the mixture.
Cover with plastic wrap, placing the wrap directly on top of the pastry cream so it doesn’t get a film on top.
Then chill until ready to use, at least two hours or overnight.