interface Named {
readonly name?: string;
outputName?: string;
}
? : optional property
interface Named {
readonly name?: string;
outputName?: string;
}
interface Greetable extends Named {
greet(phase: string): void
}
class Person implements Greetable, Named {
name?: string;
age = 30
// 인터페이스에 없는 more field/ more mehtod 넣을 수 있다
// avaiable for extending this class
constructor(n?: string){
if(n) {
this.name = n
}
}
greet(phrase: string): void {
if(this.name){
console.log(phrase + ' ' + this.name);
} else {
console.log('hi')
}
}
}