One of the challenges I am facing involves adding data to local storage using a function:
add(type: "point" | "object", body: FavouritesBodyPoint | FavouritesBodyObject) {
// TODO
}
export interface FavouritesBodyPoint {}
export interface FavouritesBodyObject {}
The issue at hand is my desire to expand the options for both type
and body
when adding data. I am wondering whether I should create a new function or if utilizing union types would be a viable solution.
I am seeking ways to achieve polymorphism in this context.