and more!
Note: types are optional
private trunk: string = 'default text';
public count: number = 0;
var test = function (trunk: String) {
//I do stuff
}
class ESport {
private type: string = 'FPS';
constructor (type: string) {
this.type = type;
}
}
class StarCraft extends ESport {
constructor () {
super('RTS');
}
setType: void (type: string) {
this.type = type;
}
}
var sc = new StarCraft();
sc.setType('Real Time Strategy');interface Type {
name: string;
players: number
}
interface Player {
name?: string;
skill?: string;
type?: Type;
started?: date;
}
class ESport {
private type: Type = {
name: 'FPS'
};
private Player: Player = {
name: 'Husky',
type: type,
skill: 'Commentator'
}
constructor (type: string) {}
}function g() {
console.log("g(): evaluated");
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
console.log("g(): called");
}
}
class C {
@g()
method() {
// g decorates this function with additional
// functionallity that makes extending code easier
}
}