I'm trying to figure correct way to map Interface record value types to correct 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,
});
So idea is that when creating builder it check that all Interface keys are in place and someway also do value mappings like Interface "string" => requires "() => string" which compose functions should be filling. Before I did similar setup, but there was tons of never checks and performance was really bad to solve those so I think there should be much easier way actually to do this.