I want to define a payload with different forms of interface in one function.
Each payload is as follows and I have defined the "UpdatePayload" interface as follows:
/*
ex) payload interface
const interface updateBodyPayload = {
title: ...
content: ...
}
*/
/*
ex) payload interface
const interface updateStatePayload = {
type: ..
count: ..
}
*/
// Payload Merge interface
export type updatePayload = Partial<updateBodyPayload | updateStatePayload>;
However, the code inside the function produces the following error:
// function.ts
const exec = (body: updatePayload) => {
const { title, content, type, count } = body;
// -> property 'title', ... does not exists on type updatePayload
}
What did I make a mistake?