function hellosString(message: string): string {
return message;
}
function helloNumber(message: number): number {
return message;
}
// 더 많은 반복된 함수들이 생길 수 있다.
function hello(message: any): any {
return message;
}
console.log(hello('malza').length); // any 가 무슨 짓을 하든 관여하지 않는다.
console.log(hello(123));
function helloGeneric<T>(message: T): T {
return message;
}
console.log(helloGeneric('malza').length); // 메소드 자동완성 된다.
console.log(helloGeneric(123));