摘要:
类型兼容性用于确定一个类型是否能赋值给其他类型。 any 任何类型都能被赋值给any let foo: any = 123; foo = 'hello'; 结构化 TypeScript 对象是一种结构类型,因此只要结构匹配就是兼容的 interface Point1 { x: number; y: 阅读全文
摘要:
申明为 void 类型的变量,只能赋予 undefined 和 null。因此一个函数如果返回值是void类型,返回值只能是null或undefined let unusable: void = undefined; // OK function fn(): void { return null } 阅读全文