Preheat your oven to 350°F (175°C). Grease and flour a baking pan.
In a mixing bowl, whisk together the flour, baking powder, baking soda, cinnamon, nutmeg, ginger, and salt.
In another bowl, beat the sugar, oil, and eggs until well combined.
Gradually add the dry ingredients to the wet ingredients, mixing until just combined.
Fold in the grated carrots and walnuts (if using).
Pour the batter into the prepared baking pan and bake for 45 minutes, or until a toothpick inserted into the center comes out clean.
Allow the cake to cool in the pan for 10 minutes, then transfer to a wire rack to cool completely.