interface MyType {
'font-size' : number,
[key :string] : number | MyType,
}
let obj = {
'font-size' : 10,
'secondary' : {
'font-size' : 12,
'third' : {
'font-size' : 14
}
}
}
이런식으로 짜면 object가 연속되는 경우에도 에러없이 작성이 가능
interface StringOnly {
age : number, ///가능
[key: string]: string | number,
}
-------------------------------------------------------------------------------
interface StringOnly {
[key: string]: string
}
let obj :StringOnly = {
name : 'kim',
age : '20',
location : 'seoul'
}
이런식으로 사용가능!