Take for example this TypeScript code:
interface IBook {
metadata: {} | {
title: string;
author: string
};
}
const bookOne: IBook = {
metadata: {}
};
const bookTwo: IBook = {
metadata: {
TEST: 'Red Book',
}
};
As you can see, metadata can only be an object. But, what I'm trying to figure out, how do I make it either empty object ({}) or if it needs to have properties within that object to make it only title and author.
I think I know why it's wrong but I can't seem to find the either. Help?