Hacker News new | ask | show | jobs
by scriby 3701 days ago
The .ts files will be compiled to AMD modules, so none of the declarations will be in the global scope.
1 comments

Thanks, I had not seen that before. Interesting trick: Call a "registration" function with a string array (of dependencies) and an anonymous function (IIFE) with parameters for each dependency which the registration function injects. Thus, the dependencies are accessed as closures over the outermost func's params, rather than as globals.

E.g. -

    define( [ 'jQuery' ], function ( $ ) { ... return { ... } } )
where the 1st elipses are all the private/setup code, and the second elipses are whatever methods/properties the module exports. (this dummy only wants jQuery, but the list can be longer)