标签:lang rip 无法 变量类型 类型 使用 number not 自动
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 无法分析变量类型的话, 我们就需要使用类型注解
TypeScript 类型注解和类型推断
标签:lang rip 无法 变量类型 类型 使用 number not 自动
原文地址:https://www.cnblogs.com/xch-jiang/p/14179164.html
暂无评论...