Exercise: Simple TypeScript

Idea: Introduction to TypeScript.
Background: Classes: http://www.typescriptlang.org/docs/handbook/classes.html Interfaces: https://www.typescriptlang.org/docs/handbook/interfaces.html

Create a new folder: "Exercise1-typescript" in your VSCode project folder.
Start VSCode and open the new folder.
Create a new file: "simple-typescript.ts"
Open an integrated terminal window in VSCode: view->Integrated Terminal

Start the TypeScript compiler and let the compiler watch the file (type tsc simple-typescript.ts in the terninal window)
Notice: it creates a new empty file: "simple-typescript.js"

In the ts file create an interface called IVATCalculator with a single method called calculate.
The method should have a single parameter called amount of the type number and it should return a number as well.
In the same file create a class with the name VATCalculator, and let the class implement the interface IVATCalculator

Implement the method calculate. The method should return the amount with VAT of 25% added to it.

Create an instance of this class and assign it to a const called vat of the type IVATCalculator.

Create some log-statements like:
console.log(vat.calculate(100)); to test the class.

View the to files by using the Split Editor

Save the file and compile the ts file and execute the JS file with
tsc simple-typescript.ts
node simple-typescript.js

Verify the output!

Enjoy ;-) / Henrik H