It took me a while but I managed to create a workaround for this problem but that doesn't do anything either, even though it works for a while it goes back to the wrong sorting for some reason after a while I also tried to package it into an interface and somehow load it from there properly but apparently this is a bug that can't be fixed manually.
type Union_To_Spread<Object_Input> = {
[Key in keyof Object_Input]: Object_Input[Key]
};
type Array_Into_Record<
Input extends number[],
Result extends Record<number, never> = {}
> = Input extends [
infer First_Number extends number,
...infer Rest_Numbers extends number[]
] ? Array_Into_Record<
Rest_Numbers,
Union_To_Spread<{ [K in keyof Result]: Result[K] } & { [K in First_Number]: never}>
> : keyof Result;
type number_list = Array_Into_Record<[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]>;
const valid: number_list = 25;
const invalid: number_list = 30;