I have created a union type called DataType,
type TextData = string
type BinaryData = Blob
type DataType = TextData | BinaryData
Now, I want to implement it in a function
function processData(data: DataType): void {
if (data instanceof TextData)
// encountering an error when using the type as a value
if (typeof data === 'Blob')
// getting an error because typeof data is 'object'
if (data instanceof Blob)
// this works, but I prefer not to use a type alias
}
Is there a way to make this work, or should I consider redesigning the approach?