Html
Create a new file 1.html and write the code:
File 1.html Download
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<!-- include js script -->
<script src="app.js" ></script>
<!-- my script -->
<script>
var book1 = new Book("Count of Montecristo", 40);
alert(book1.name + " " + book1.price);
</script>
</body>
</html>
TypeScript
Create a new file app.ts and write the code:
File app.ts Download
class Book
{
name : string;
price : number;
constructor(newName: string, newPrice: number)
{
this.name = newName;
this.price = newPrice;
}
}
run in the command line:
Command Prompt (Win Console)
tsc app.ts
Note!
It happens that the command does not work
tsc
Therefore, look for the file
tsc.exe and run at the command prompt:
Command Prompt (Win Console)
"C:/Program Files (x86)/Microsoft SDKs/TypeScript/3.1/tsc.exe" app.ts