TypeScript 4.9 で新たに導入される satisfies 演算子にとても期待しています。個人的に役に立ちそうだと思ったユースケースとして、switch や if で union を順番に処理していくときの網羅性チェックが挙げられます。 declare const difficulty: "easy" | "medium" | "hard"; switch (difficulty) { case "easy": case "medium": case "hard": break; default: // OK throw new Error(difficulty satisfies never); } switch (difficulty) { case "easy": case "hard": break; default: // Type 'string' does not
