06-类型推论和类型别名
小于 1 分钟
类型推论|类型别名
类型别名
type 关键字(可以给一个类型定义一个名字)多用于符合类型
定义类型别名
type str = string
let s:str = "我是小满"
定义函数别名
type str = () => string
let s: str = () => "我是小满"
定义联合类型别名
type str = string | number
let s: str = 123
let s2: str = '123'
定义值的别名
type value = boolean | 0 | '213'
let s:value = true
//变量s的值 只能是上面value定义的值