You can make modelValue a discriminated union key by range so TS can infer the correct type automatically. For example:
type Props =
| { range: true, modelValue: [number, number] }
| { range?: false, modelValue: number };
Then use that type in your defineProps and defineEmits so no casting is needed.