To make the filling, heat the milk and vanilla to boiling point.
Meanwhile, whisk the egg yolks and caster sugar until pale, then stir in the cornflour.
Pour the hot milk over the egg yolk mixture and whisk until smooth.
Return to the pan and heat gently, stirring constantly, until thick.
Put the thick custard into a clean bowl, add the chocolate and stir until melted.
Cover the surface with cling film and leave to cool completely.