11.1、类型别名
// type aliase
// 普通写法
let sum: (x: number, y: number) => number
const result = sun(1, 2)
// 类型别名写法
type PlusType = (x: number, y: number) => number
let sum2: PlusType
const result2 = sun2(1, 2)
11.2、字面量
const str: 'name' = 'name'
const number: 1 = 1
type Directions = 'Up' | 'Down' | 'Left' | 'Right'
let toWhere: Directions = 'left'
11.3、交叉类型
interface IName {
name: string
}
type IPerson = IName & {age: number}
let person: IPerson = {name: '123', age: 123}