How come the default case in the switch statement below does not result in an exhaustive check where 'item' is correctly identified as of type 'never'?
enum Type {
First,
Second
}
interface ObjectWithType {
type: Type;
}
const array: ObjectWithType[] = [];
for (const item of array) {
switch (item.type) {
case Type.First:
break;
case Type.Second:
break;
default: {
const unhandledItem: never = item;
throw new Error(`Unhandled type for item: ${unhandledItem}`);
}
}
}