Bart van den Burg Bart van den Burg - 1 year ago 47
TypeScript Question

Typescript: How to organize an app

Here's something I can't wrap my head around. I have these typescript files:

// app.ts
import {SomethingService} from "./something";
new SomethingService().yay();


// something.ts
export class SomethingService {
yay() {


// index.html
<script src="require.js"></script>
<script src="app.js"></script>


I then compile the TS with:
tsc app.ts --module amd --outFile app.js

However, because of the import statement, app.ts is treated as a module and the actual code is never executed. The alert never pops up. How do I make sure the code in app.ts is executed?

Answer Source

So here it is you need to tell require.js to handle it.

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