TypeScript 类型注解和类型推断
type annotation 类型注解
let count: number;
count = 1;
type inference 类型推断
const one = 1;
const two = 2;
const three = one + two;
const person = {
name: "张三",
age: 45,
};
使用:
- 如果 TS 能够自动分析变量类型, 我们就什么也不需要做了
- 如果 TS 无法分析变量类型的话, 我们就需要使用类型注解

浙公网安备 33010602011771号