Drew Noakes
Drew Noakes

Reputation: 311185

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

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.

Upvotes: 18

Views: 8930

Answers (3)

duracell
duracell

Reputation: 724

in your package.json-> devDependencies part insert "fast-deep-equal": "^3.0.0",

than it should function

Upvotes: 0

basarat
basarat

Reputation: 276085

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:

enter image description here

Source: Microsoft Blog

Upvotes: 22

Drew Noakes
Drew Noakes

Reputation: 311185

TypeScript 0.9 is not backwards compatible with prior versions. You must prefix the top level element (probably a module) with the declare keyword.

Upvotes: 2

Related Questions