This project is read-only.

Extending Window interface doesn't seem to work in files with imports

Topics: General, Language Specification
Jul 2, 2014 at 1:16 AM
See this example. I'd expect to be able to use as a string, but window seems to not get typed correctly. Am I missing something? I realize that the import path isn't valid in that example, but that's not the issue at hand - I couldn't figure out how to replicate a working import in the playground, but in my local file that's hitting this issue the import is valid and isn't throwing any errors.
Jul 2, 2014 at 5:40 PM
When you use imports in a file, it changes that file to be an external module. This changes its namespace from the default namespace to be newly-created namespace for the external module. To be able to change what is in Window, you need to do so from the global namespace. You should be able to move the interfaces that augment Window from inside the external module to a .d.ts file that is ///reference'd by the external module.
Jul 2, 2014 at 6:06 PM
Ah yeah, that makes sense - although it is certainly a bit awkward. It would be quite nice to have a way to declare types in the global namespace from inside files that have imports. Thanks for your help!