1class Person {
2
3 private firstName: string;
4 private lastName: string;
5
6 constructor(firstName: string, lastName: string) {
7 this.firstName = firstName;
8 this.lastName = lastName;
9 }
10
11 public getFullName() {
12 return `${this.firstName} ${this.lastName}`;
13 }
14}
15
16export = Person;
1interface Task{
2 name: String; //property
3 run(arg: any):void; //method
4}
5
6class MyTask implements Task{
7 name: String;
8 constructor(name: String) {
9 this.name = name;
10 }
11 run(arg: any): void {
12 console.log(`running: ${this.name}, arg: ${arg}`);
13 }
14}
15
16let myTask: Task = new MyTask('someTask');
17myTask.run("test");
1interface Animal { name: string; size: "small"; medium; large;}const animalsArray: Animal[] = [ { name: "chicken", size: "small" }, { name: "pig", size: "medium" }, { name: "cow", size: "large" },];