Prepare the crust. In a bowl, mix the cookie crumbs, sugar, and salt. Pour in the melted butter and stir until the mixture resembles wet sand.
Press and chill. Firmly press the crumb mixture into a 9-inch pie dish, covering the bottom and sides evenly. Use a flat-bottomed glass for a tight, compact crust.
Chill in the fridge for at least 20 minutes.
Start the filling base. In a medium saucepan, whisk together sugar, cornstarch, and salt. Add the milk (and cream, if using) gradually, whisking until smooth. Whisk in the egg yolks.
Cook until thickened. Place the pan over medium heat and cook, whisking constantly, until the mixture thickens and starts to bubble, 5–7 minutes.
Let it bubble for 30–60 seconds while whisking to cook off the starch taste.
Add chocolate and flavorings. Remove from heat. Stir in the chopped chocolate, butter, and vanilla until smooth and glossy.
Cool slightly. Transfer the filling to a bowl. Press a piece of plastic wrap directly onto the surface to prevent a skin.
Let it cool to warm room temperature, about 20 minutes.
Fill the crust. Pour the warm filling into the chilled crust and smooth the top. Cover the pie loosely and refrigerate until set, at least 4 hours or overnight for the cleanest slices.
Whip the topping. In a cold bowl, beat the heavy cream, powdered sugar, and vanilla to soft peaks. Spread or pipe over the chilled pie.
Garnish and serve. Add chocolate shavings or a dusting of cocoa powder.
Slice with a sharp knife, wiping the blade between cuts for neat slices.