TypeScriptで外部から受け取った値が Union Type に含まれるかどうかを検証したいとき、パッと思いつく方法として、 Array.includes() を使用するというものがあります。 const colors = ["red", "green", "blue"] as const; type Color = typeof colors[number]; // = "red" | "green" | "blue" declare const input: string; if (colors.includes(input)) { // do something } > tsc --noEmit hello.ts:5:21 - error TS2345: Argument of type 'string' is not assignable to parameter of ty