🤖

if文の式で配列を使う方法

2025/01/25に公開

結論 Array.isArray()で型を絞る

type formState = { bool: false | [true, string] | null };
if (Array.isArray(bool) && bool[0] === true) {}

型を絞ることで配列を扱えるようになる

Discussion