Click here to Skip to main content
15,886,091 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can anyone create and let us download a simplest project using VisualStudio 2015 + TypeScript 1.7.6.0 that would use a CommonJS or AMD module type? Something like this (for CommonJS module type in project settings):

-- index.html --
HTML
<!DOCTYPE html>
<html>
<head>
    <script src="http://requirejs.org/docs/release/2.1.22/minified/require.js"></script>
    <script src="a.js"></script>
    <script src="app.js"></script>
</head>
<body>

</body>
</html>


-- a.ts --
JavaScript
export class a {
    f1: string;
}


-- app.ts --
JavaScript
import {a} from './a';

var _a = new a();
_a.f1 = 'Hello world!';

alert(_a.f1);


I get the following error for this:

Unhandled exception at line 6, column 1 in http://localhost:3285/a.js
0x800a1391 - JavaScript runtime error: 'exports' is undefined

a.js that I get is this:
JavaScript
var a = (function () {
    function a() {
    }
    return a;
})();
exports.a = a;
//# sourceMappingURL=a.js.map



What am I missing?

Thanks,
Vadim
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900