I am working with a function that can return either a string or an object.
Here is an example:
myFunc(path: string): string | object
If I already know the exact structure of the object that I am expecting, how can I ensure that the function returns a type that matches MyObjectProps
instead of just object
?
For instance:
type MyObjectProps = {
a: string;
b: string;
}