In a large saucepan, mix sugar, cornstarch and salt. Whisk in milk until smooth. Cook and stir over medium heat until thickened and bubbly. Reduce heat to low; cook and stir 2 minutes longer. Remove from heat.
In a small bowl, whisk a small amount of hot mixture into egg yolks; return all to pan, whisking constantly. Bring to a gentle boil; cook and stir 2 minutes. Reduce heat to low; stir in chocolate until melted. Remove from heat; stir in vanilla. Cool 15 minutes, stirring occasionally.
Transfer to a bowl; press plastic wrap onto surface of pudding. Refrigerate until cold. If desired, serve with whipped cream.