0
我試着寫一些像這樣的代碼:如何在TypeScript中的二維數組上輸入guard?
const x: string[] | string[][] = blah();
if (Array.isArray(x[0])) {
// I expect x to be inferred to be string[][] here, but it's not!
}
怎麼會不能由此推斷x
是一個二維數組?我做錯了什麼,或者是TypeScript?