1

I am working on first part of this answer

When I compile main.ts to js

require("amd-loader");
import someModule = require('../mymodule')
var someClass  = new someModule.MyNamespace.MyClass();

it becomes:

define(["require", "exports", '../mymodule'], function (require, exports, someModule) {
    require("amd-loader");
    var someClass = new someModule.MyNamespace.MyClass();
});

then it gives me define is not defined error

When I modify it as below, error goes away.

require("amd-loader");
define(["require", "exports", '../mymodule'], function (require, exports, someModule) {
    var someClass = new someModule.MyNamespace.MyClass();
});

Then I get Cannot read property 'MyClass' of undefined error

How can I get fix these error and get it work as expected as mentioned in that Q&A?

My environment is Visual Studio 2015 and I compile with AMD options as module system(obviously I tried each options). I am doing angular protractor e2e tests

2

1 Answer 1

1

As said by basarat at this answer, CommonJS should be used in this case.

In Visual Studio 2015 version 14.0.23.107.0, it seems TypeScript Module System options does not work, and it compiles always with whatever any one selected

enter image description here

So following this post CommonJS can be selected.

And voila it compile in with CommonJS and works as expected

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.