error TS1046: 'declare' modifier required for top level element

typescript

Solution

This was a breaking change between 0.8.x vs 0.9.x. `declare` is now required for all top level non-interface elements (i.e. `module`, `class`, `var`) in a declaration `.d.ts` file:

Source: Microsoft Blog

Problem

I'm using a `.d.ts` definition file I found online for interoperating with a JavaScript library. I'm seeing the error message: TS1046: 'declare' modifier required for top level element What is causing this? I'm using TypeScript 0.9.1.

Original source