const A = {
s: string,
}
const AMapsTo = {
someAProperty: string,
}
const B = {
n: number,
}
const BMapsTo = {
someBProperty: string,
}
const a: A = {s: "cool"}
const b: B = {n: 0}
const aMaps: AMapsTo = {someAProperty: "cool"}
const bMap: BMapsTo = {someBProperty: "cool"}
const myMapping = [[a, aMaps], [b, bMaps]]
// Doesn't have to look exactly like this
function myBuilderFunction(myMapping) {
// ...
// Some type safe function. When called with A the type is inferred as AMapsTo
return (preMappingValue: SomeType)=>SomeTypeMapsTo
}
const fn = myBuilderFunction(myMapping);
fn(a) // Typed as AMapsTo
const A = {
s: string,
}
const AMapsTo = {
someAProperty: string,
}
const B = {
n: number,
}
const BMapsTo = {
someBProperty: string,
}
const a: A = {s: "cool"}
const b: B = {n: 0}
const aMaps: AMapsTo = {someAProperty: "cool"}
const bMap: BMapsTo = {someBProperty: "cool"}
const myMapping = [[a, aMaps], [b, bMaps]]
// Doesn't have to look exactly like this
function myBuilderFunction(myMapping) {
// ...
// Some type safe function. When called with A the type is inferred as AMapsTo
return (preMappingValue: SomeType)=>SomeTypeMapsTo
}
const fn = myBuilderFunction(myMapping);
fn(a) // Typed as AMapsTo