everything is working correctly except that
the output function returns the StructToObject but the result is still "wrapped". I want it to show the type that you would get when you use typeof on the result
interface StructuredType<T> {}
const bool: StructuredType<boolean> = {};
const uint8: StructuredType<number> = {};
interface Property { [key: string]: StructuredType<any>; };
type InferStructuredType<T> = T extends StructuredType<infer U> ? U : never;
type StructToObject<T extends readonly Property[]> = {
[K in T[number] as keyof K]: InferStructuredType<K[keyof K]>;
}
class Structured<T extends readonly Property[]> {
constructor(public struct: T) {}
output(): StructToObject<T> {
// @ts-ignore
return {};
}
}
const b = new Structured([{x: bool}, {y: uint8}] as const);
// shows incorrectly
const result = b.output()
// shows correctly
type bruh = typeof result