I'm a newbie in TypeScript, and I want to use multiple files for my code, using TypeScript version 0.9.0 and Visual Studio. I think I made right codes, and IntelliSense seems it think so too, but it fails when I actually run it, throwing JavaScript undefined exception.
I have two .ts files which are app.ts and module.ts, and this is my short codes.
module.ts is here:
module Shapes {
export class Rectangle {
constructor(
public height: number,
public width: number) {
}
}
}
and app.ts is here:
/// <reference path="app/classes/module.ts" />
var rect = new Shapes.Rectangle(10, 4);
IntelliSense correctly detects what is 'Shapes' and what is 'Shapes.Rectangle', but when I run this code, the error says that 'Shapes' is undefined.
So I searched the web and found some articles including this and this, I followed their tips, but I failed. I can't understand why...
This is my default.htm code.
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>TypeScript HTML App</title>
<link rel="stylesheet" href="app.css" type="text/css" />
<script src="app/classes/module.js"></script>
<script src="app.js"></script>
</head>
<body>
<h1>TypeScript HTML App</h1>
<div id="content"></div>
</body>
</html>
I think I correctly added module.js into the HTML file. Can anyone help me?