4

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.

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

2 Comments

I thought module keyword was not fully deprecated. Is it not still active in declare module "foo" { ...} (with quotation marks) for ambient modules? (maybe that is what you meant by "in this case")
Yes. That is what I meant with in this case 🌹

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.