// 我们给 numericValue 设置为 number
let numericValue: number = 15
// 但是当我们想要使用这个变量赋值 string 的时候就会报错
numericValue = '15'
// 这样就同时兼容 number 和 string 类型了
let numericValue: number | string = 15
let args: string | string[]
args = 'value1'
args = ['value1', 'value2', 'value3']
2.
interface Product {
title: string,
price: number
}
let product: string | Product
product = '牛仔裤'
product = {
title: '牛仔裤',
price: 200
}
string | number | boolean | string[]