TypeScript 没有对结构体的属性初始化或者没有给对象属性初始化 未初始化的字段都是undefined
interface Animal { name: string; age: number; egg?: number; } let animal: Animal = <Animal>{}; console.log('------------------------'); console.log(animal.name); console.log('------------------------'); console.log(animal.age); console.log('------------------------'); console.log(animal.egg); console.log('------------------------');