简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM