switch(JSON.parse(`"INVALID VALUE"`) as MyEnum) { case "Hoge": return something; case "Huga": return something; default: throw new Error(a); } | "Piyo"
{ // = never super(`Invalid value: ${value}`); } } type MyEnum = "Hoge" | "Huga" | "Piyo"; switch(JSON.parse(`"INVALID VALUE"`) as MyEnum) { case "Hoge": return something; case "Huga": return something; default: // case value: never // value: never // Type '"Piyo"' is not assignable to type 'never'. throw new InvalidMyEnumError(value); }