// 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)
const str: ‘name‘ = ‘name‘
const number: 1 = 1
type Directions = ‘Up‘ | ‘Down‘ | ‘Left‘ | ‘Right‘
let toWhere: Directions = ‘left‘
interface IName {
name: string
}
type IPerson = IName & {age: number}
let person: IPerson = {name: ‘123‘, age: 123}
原文:https://www.cnblogs.com/shixiaokeng/p/14678343.html