In a medium saucepan, combine the granulated sugar, light brown sugar, water, and molasses.
Split the vanilla beans and scrap the seeds into the pan. Whisk to combine and add the pods (if using vanilla extract, do not add until after simmering the syrup).
Add the cinnamon sticks, ginger, allspice berries, cloves, black peppercorns, and pinch of salt.
Bring the mixture to a boil, then reduce heat to a simmer.
Cook, whisking occasionally, until the sugar is dissolved and the liquid is starting to thicken slightly, 10-15 minutes.
Remove from heat, cover, and allow to steep for 30 minutes.
Strain the syrup through a fine mesh strainer and discard the spices. Transfer the syrup to an airtight container and refrigerate for up to 2 weeks.