1

I'm using VS2015 and I've created a TypeScript HTML application. I also made the simplest possible external module, like this.

export class MyClass {
    public Test(): string {
        return "Erik";
    };

    constructor() {
    };
};

Then in my app.ts file i wrote the following.

import E = require('./Erik');

window.onload = () => {
    let c: E.MyClass = new E.MyClass();
    alert(c.Test());
};

Using F12 dubugging in Chrome I can see this error.

Uncaught ReferenceError: define is not defined

What am I missing? I have made sure that AMD moduletype is selected in the project settings and a Erik.js file is created when compiling.

1 Answer 1

4

You still need to use a module loader library that works with AMD modules.

For example, you could include require.js in your application, then do something along these lines:

<script data-main="scripts/app" src="scripts/require.min.js"></script>

Where data-main is the path to app.js.

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.