let names: (string | string[])[] = ['a', ['b']]
let aaa = names.reduce(result => {
return result
}, [] as string[])
为什么最后 aaa 的类型是 string | string[] 呢?百思不得其解
let names: (string | string[])[] = ['a', ['b']]
let aaa = names.reduce(result => {
return result
}, [] as number[])
用 number 后出来的是期望的 number[],这为什么二者会不一样呢?