Warm the milk in a saucepan then set aside, being careful not to boil it. Scrape the vanilla beans from the pod and add (if using extract, you will add this later).
Briskly whisk the egg yolks and sugar together until pale in another bowl, a couple of minutes. Add the cornstarch and salt and mix until it is smooth.
Very slowly pour the warm milk into the egg mixture while whisking constantly. This step, known as tempering, is very important for avoiding a lumpy custard.
Return the egg and milk mixture back to the saucepan and heat it on a medium-low heat, stirring constantly.
Keeping an eye on the temperature, stir the mixture constantly with a whisk until the mixture is very thick (about 10 minutes). Turn the heat down to low if lumps are forming or the bottom is burning. Whisk in the vanilla extract (if you are not using vanilla bean).
Remove from the heat and pour the pastry cream into a bowl. Cover with plastic wrap directly on top, being sure that the plastic is touching the surface of the pastry cream to prevent a skin from forming.
Chill for at least 3 hours.