By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. In the following code, you are exporting the newUser variable: Since the variable newUser was exported, you can access it as a property of the namespace. TypeScript supports two methods to organize code: namespaces and modules, but namespaces are disallowed. I had to delete the declare module "mymodule" line and then it worked. I am doing this, because this way I have a consistent namespace. The compiler will try to find a .ts, .tsx, and then a .d.ts with the appropriate path. The sample function runs the while loop for infinite times, and it will never stop. With this context, you can now run through a common use case for namespaces: Defining types for external libraries without typing. Unlike modules, they can span multiple files, and can be concatenated using outFile . Do not hesitate to share your response here to help other visitors like you.