// type annotation 类型注解,我们来告诉ts变量是什么类型// type inference 类型推断, TS会自去尝试分析变量类型// 如果 TS 能自动分析变量类型,我们不需要做什么// 如果 TS 无法分析,我们就需要类型注解let count: number;count = 123;let countInference = 123;const firstNumber = 1;const secondNumber = 2;const total = firstNumber + secondNumber;// 这种情况下 不知道具体类型,所以需要加注解function fn_total(a: number, b: number) {return a + b;}const res = fn_total(firstNumber, secondNumber);
typescript就是让所有的变量都有具体类型
