Skip to content

Instantly share code, notes, and snippets.

@esimov
Last active October 11, 2015 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esimov/3931489 to your computer and use it in GitHub Desktop.
Save esimov/3931489 to your computer and use it in GitHub Desktop.
Interface implementation in Typescript
interface Package {
person: {
firstName?:string;
lastName?:string;
age:number;
action: string;
};
status: {
married?:bool;
haschild?:bool;
};
}
class Person implements Package {
person : {firstName:string; lastName:string; age:number;};
constructor(action:string, age:number) {
this.person = {
firstName: "Miklos",
lastName: "janos",
age: (age || 22),
action: Person.getAction(action)
}
}
log() {
console.log(this.person);
}
static getAction(action) {
return "Perform the following action: " + action;
}
}
var person = new Person("running", 22);
person.log();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment