타입 추론
점진적 타입 시스템
타입추론이 가능한 상황
let a = 10; // number로 추론
let b = "hello"; // string으로 추론let c = {
id : 1,
name '신봄',
profile : {
nickname : 'bom',
}
}
let { id, name, profile } = c주의해야 할 상황
마지막 업데이트
function func() {
return "hello";
}
// function func() : stringfunction func(message = "hello") {
return "hello";
}
// function func(message : string) : stringlet d;
// d: any
d = 10;
d.toFixed();
// d: number
d = "hello";
d.toUpperCase();
// d: string
d.toFixed(); // 오류let e: any;
e = 10;const num = 10;
// num : 10
const str = "hello";
// num : 'hello;let arr = [1, "string"];
// (string | number) []