Heat milk slowly in a medium-sized pot over medium-low heat until steam rises, about 7 minutes.
In the meantime, beat eggs until lemon-coloured in a heatproof bowl. Beat in sugar, cornstarch and flavouring.
Pour hot milk in a slow and steady stream into the egg mixture, whisking constantly. Once all the milk is incorporated, pour the whole mixture back into the pot and cook over medium-low heat, stirring constantly with a wooden spoon, until the custard is thick enough to coat the back of the spoon, about 10 minutes. You’ll notice the custard thickening as you stir.
If the custard curdles, pour it through a strainer into a bowl and whisk vigorously for a few minutes. It should come together. Cool to room temperature before adding it to the trifle.