原始类型
const num: number = 12
const str: string = '你好世界'
const flag: boolean = false
const nu: null = null
const und: undefined = undefined
数组类型
// 数组类型
// 写法一(推荐)
const arr: number[] = [1, 2, 3, 4, 5]
// 写法二
const arr2: Array = [1, 2, 3, 4, 5, 6]
联合类型
// 联合类型(注意有没有括号区别)
// 带括号谢安的意思, 数字联合字符串类型 组成的数组
const arr3: (number | string)[] = [1, '2']
// 不带括号写法的意思, 数字 和 字符串数组 联合的类型, 要么数字, 要么数组, 如果是数组, 就只能装字符串
const arr4: number | string[] = ['s', 'd']
类型别名
type TimerId = number | null
let timer: TimerId = null
let timer2: TimerId = null
// let timer3: number | null = null
<