Typescript first steps.
├── build
├── dev
└── tsconfig.json
- In build directory you can find js and js.map files (transpilation outputs).
- In dev directory you can ts files.
- typescript tsc configuration file tsconfig.json
- outputs are in es5 format
function hello world
Hello, World!
first class
elephant object = [object Object]
bigger class with getters, setters, constructor with params, access keywords
elephant => name = elephant 2, age = 10, vaccination = true
trick how you can have overloaded methods (technicaly still one method) and multiple constructors (technically still one constructor) and lambda example.
tiger1 => name = Tiger1, age = undefined, vaccination = undefined
undefined
24
undefined
24
tiger2 => name = Tiger2, age = 14, vaccination = undefined
14
13
14
13
tiger3 => name = Tiger3, age = 10, vaccination = true
10
10
10
10
- interface
- enum
=> name = Audi R8 => speed = 230 => price = 3500 => sport = true
=> name = BMW => speed = 220 => price = 4500 => sport = undefined
- inheritance
- abstract class
- toString
- instanceof
It is Ferrari
{ name: 'My Ferrari', sport: true, toString: [Function] }
Vehicle = [ name : My Ferrari , sport : true , speed : 250 , price : 5600]
It is Ford
{ name: 'My Ford', sport: false, toString: [Function] }
Vehicle = [ name : My Ford , sport : false , speed : 190 , price : 3000]
- usage of type keyword
- object literals
- varargs
- Function type
- arrays
- tuples
hello world
one
two
one
8
2
20
first
second
third
11-22-333
9
2
- Generics
string is there.
string
Vehicle is there.
Vehicle
You need to install Nodejs.
This examples were created with WebStorm configured