TypeScript希望开发者写出的代码中每个变量的类型都是确定的,而想要做到这一点就需要类型注解和类型推断。 类型注解(Type annotation) 所谓类型注解,就是人为为一个变量指定类型,例如: const count: number = 123; const word: word = '123'; // TypeScript中一个变量的类型并不一定是固定的,例如 let temp: string | number =