I just want to have an object with dynamic properties like ( get , post, put )
type methodNames = "get" | "post" | "put";
interface toFetch {
target:string,
from: string
}
type CommonApiQuery = Record<methodNames, toFetch[]>
I want the CommonAPIQuery to allow objects something like below:
const lookup : CommonApiQuery = {
get: [{target:"students",from:"id"}]
}
But its expecting properties "post" and "put" also. I just want to have atleast one of the defined properties in methodNames, but should throw error when no property from methodNames is defined. How to achieve that ?