Feature or bug?

Topics: General
Sep 30, 2013 at 1:16 PM

function Auto(arg0: any, arg1?: any) {
 
}
Gives:
function Auto(arg0, arg1) {
}
HOWEVER:
export interface IResolverFactory {
}

function Auto(arg0: any, arg1?: any) {
 
}
Gives:
define(["require", "exports"], function(require, exports) {
    function Auto(arg0, arg1) {
    }
});
Which makes Auto unavailable in the global namespace.
What gives?
Coordinator
Sep 30, 2013 at 5:31 PM
A file with a top-level 'export' directive is an external module. External modules are intended to prevent leaking objects into the global namespace. We don't allow for mixing of external and non-external module code in the same file.
Sep 30, 2013 at 5:53 PM
Got it. Perhaps issuing a warning would be useful - it took me a while to figure out why 'Auto' wasn't available any longer.
Coordinator
Sep 30, 2013 at 6:22 PM
It's very typical for external modules to only export some of their functions; e.g. in this case 'Auto' might be an implementation detail used by some other exported type. There's really nothing to warn about at all.
Sep 30, 2013 at 6:41 PM
Edited Sep 30, 2013 at 6:41 PM
In my case, the functions were not referenced in that file and couldn't have been referenced from another file because of the export and me not being aware of what JS that would produce.
So, at least an "unreferenced symbol" warning?