Jonas Kello
Jonas Kello

Reputation: 1402

Typescript module syntax

In typescript, what is the difference between these two:

declare module foo { ... }

and

declare namespace foo { ... }

From the docs I get the feeling they should be the same and the second one is preferred. However I see many .d.ts files that uses the first one which makes me unsure.

Upvotes: 4

Views: 399

Answers (1)

basarat
basarat

Reputation: 276383

They are exactly the same. The keyword module was deprecated in favor of namespace in this case.

More

This is because module confuses the with the concept of file modules : https://basarat.gitbooks.io/typescript/content/docs/project/modules.html

Upvotes: 4

Related Questions