点击运行
interface Person { [key: string]: any; age: number; name: string; country?: string; } const obj: Person = { name: 'Tom', age: 30, }; obj.country = 'Chile'; obj.language = 'TypeScript'; console.log(obj);
运行结果 :
正在执行...