Skip to content

Instantly share code, notes, and snippets.

@fay-jai
Created April 4, 2016 03:20
Show Gist options
  • Save fay-jai/eb42400abe28e9cfd83bd41e6991dee3 to your computer and use it in GitHub Desktop.
Save fay-jai/eb42400abe28e9cfd83bd41e6991dee3 to your computer and use it in GitHub Desktop.
Exploring Typescript Internal and External Modules
namespace InternalModule {
export function add(...args: number[]): number {
return args.reduce((acc, cur) => acc + cur, 0);
}
}
export = InternalModule;
/*
NOTE: this is the compiled JavaScript, assuming CommonJS module format
"use strict";
var InternalModule;
(function (InternalModule) {
function add() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
return args.reduce(function (acc, cur) { return acc + cur; }, 0);
}
InternalModule.add = add;
})(InternalModule || (InternalModule = {}));
module.exports = InternalModule;
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment