Whisk the egg yolks together with the sugar and cornstarch until pale and thick. It may look like it won't come together at first but just keep mixing for a minute and it will smooth out.
Heat the milk and vanilla in a saucepan over medium heat until it is scalding hot.This means that there is steam rising from it and you can see tiny bubbles starting to appear on the surface. Do not let it boil.
Drizzle a small amount of hot milk into the egg yolk mixture and whisk, then add a little more, repeat until everything is together in the bowl, then pour the whole mixture back into the saucepan. It's important to do this slowly and gradually so you don't scramble the eggs.
Pour the custard mixture back into the pan over medium-low heat and bring it to a boil, whisking constantly. Boil for 1-2 minutes until it has thickened and you see thick bubbles bursting on the surface.
Remove from the heat. If your pastry cream has any lumps in it, pass it thorugh a fine-mesh sieve to remove them.
Add the salt and whisk in the butter one small piece at a time, making sure it melts into the mixture completely before adding the next piece.
Cover with plastic wrap (make sure the plastic wrap is touching the surface of the pastry cream to prevent a skin from forming) and refrigerate for at least two hours. I like to make this the day before and let it sit overnight, but it can be used after 2 hours.
Notes
Make sure you whisk constantly while your custard is on the heat - if you let it sit, you will end up with lumps of egg or burnt pastry cream!When your pastry cream is ready, you will be able to coat the back of a spoon and run your finger through it to make a line - the line will not fill in, it should stay visible. This means your pastry cream is cooked enough. If left to develop overnight, the custard has a much richer flavor - if you have time I highly recommend this!