Consider a use case:
// library method, I can't edit it. Its calling my custom methods
function dynamicMethod(action, params) {
....
call1[action](params);
...
}
// my custom methods
function forHuman({first, last}: {first: string; last: string }) {
...
}
function forVehicle({brand, year}: {brand: string; year: number}) {
...
}
Using the libs I m calling it
dynamicMethod('forHuman', obj); // How to get compile time error here if obj is not matching with args of forHuman??
dynamicMethod('forVehicle', obj); // How to get compile time error here if obj is not matching with args of forVehicle??