In a medium saucepan, whisk together the egg yolks, sugar, cornstarch, and salt. Whisk in the milk. Cook over medium-high heat, whisking constantly, until the mixture has thickened to the consistency of creamy salad dressing, 2 to 4 minutes.
Remove from heat and whisk in the vanilla, then the butter, a few pieces at a time, until melted and smooth. Pour into a bowl. Place a piece of parchment or wax paper directly on the surface of the pastry cream and refrigerate until completely cool, at least 2 hours and up to 2 days.