I’m trying to get the type of an exported union type by the array of it inside as represented in the playground above. What would be the best way to do this without using the Type itself (as it is non-exported)?
interface CurrentType {
a: string;
b: number;
}
type ExportedType = CurrentType | CurrentType[]
type DesiredType = CurrentType
// How can I get to DesiredType from CurrentType?
>Solution :
Exclude arrays of any type from the union
type DesiredType = Exclude<ExportedType, Array<any>>