Preheat oven to 375 degrees. In a bowl stir together flour, salt, and baking soda. In another large bowl stir together butter, both sugars, eggs, vanilla and cocoa. Gradually stir flour mixture into butter mixture and mix until combined. Stir chocolate chips and walnuts, if using, and stir to distribute evenly.
For cookies: Drop dough by tablespoonfuls onto greased baking sheets and bake about 10 minutes. Cool on a baking rack.
For bars: Pat dough into a greased 9 inch square baking pan and bake 20 to 25 minutes. Cut into squares when cooled
Recipe Courtesy of Food Network Kitchens