I am currently exploring the correct method to map Interface record value types to the appropriate function type.
function stringCompose(): string {
return ''
}
function numberCompose(): number {
return 0
}
interface Demo {
stringVal: string;
numberVal: number;
}
// mapping type something like <T = any> = (() => T)
type ComposeMapper<T = any> = any;
const builder: ComposeMapper<Demo> = ({
stringVal: stringCompose,
numberVal: numberCompose,
});
The concept is to ensure that when creating a builder, it verifies all Interface keys are present and also performs value mappings such as Interface "string" => requires "() => string" where compose functions should be applied. I previously attempted a similar setup, but encountered numerous never checks which resulted in poor performance while solving those issues. I believe there must be a simpler way to achieve this.