Topics: General
Oct 15, 2013 at 10:32 PM
Edited Oct 16, 2013 at 12:31 AM
I have a TypeScript application which uses requirejs. I am using the --module AMD switch with the compiler. The following files are an example of the structure of my application.

export module myModule {
    export class myClass {
import myModuleImport = require("Common/myModule");
Compiles to
require(['Common/myModule'], function(require, exports, __myModuleImport __){
myModuleImport seems to be undefined when referenced unless i change the compiled code to look like this.
require(['Common/myModule.js'], function(require, exports, __myModuleImport __){
Am I doing something wrong? Is this a bug in TypeScript? Is it a bug in requirejs?

EDIT: Corrected the compiled mySecondFile.js
Oct 15, 2013 at 11:57 PM
Ending a filename in requirejs with .js means that it will be loaded as a 'plain' JS file instead of a module, which probably isn't what you want.

What does the compilation of Common/myModule.ts look like? You would probably get this behavior if that file were accidently compiled with --module commonjs.
Oct 16, 2013 at 12:31 AM
Common/myModule.ts compiles to this.
define(["require", "exports"], function(require, exports) {
    (function (myModule) {
    })(exports.myModule|| (exports.myModule= {}));
    var myModule= exports.myModule;
I also made a small adjustment the MySecondDirector/mySecondFile.js code from my previous post. I had apparently left out the require and export paramters from the function.