Looks like TypeScript has a nice module system, however does this replace the need for something like requirejs? In other words, when you “compile” a typescript package does it handle all the dependency resolution for you? Examples would be appreciated!
Looks like TypeScript has a nice module system, however does this replace the need
Share
TypeScript does not have a runtime module loader. You will still need to provide a module loader to use at runtime, e.g. require js. TypeScript supports generating JavaScript code compatable with either commonJS (for node.js scripts) and AMD loaders (e.g. requireJS). To specify which one to use pass in the “–module ” switch to the compiler with either “amd” or “commonjs”.
Here is how you export a module in TypeScript:
and here is the generated JavaScript code with –module amd switch: