How can I express warningMessage is only allowed to hold a value of online or offline?
interface DataInterface {
shared?: {
bio?: string;
country?: string;
dob?: Date;
email?: string;
fullName?: string;
gender?: string;
username?: string;
warningMessage?: string; // <== How can I express this can only hold a value of online or offline?
webSite?: string;
};
}
const data: DataInterface = {};
if (true) data.shared.warningMessage = 'Online';
if (true) data.shared.warningMessage = 'Offline';
if (true) data.shared.warningMessage = "This should fail as its not 'Online' or 'Offline'";
```