Skip to content

Instantly share code, notes, and snippets.

@guillaumewuip
Created February 20, 2020 07:53
Show Gist options
  • Save guillaumewuip/1374aa818860d51da973da7110adc53e to your computer and use it in GitHub Desktop.
Save guillaumewuip/1374aa818860d51da973da7110adc53e to your computer and use it in GitHub Desktop.
How to model your entities - 6
// If this function returns true, TS will know the message variable is a TextMessage
function isText(message: Message): message is TextMessage {
return message.messageType === ‘TEXT’;
}
// Repeat for isImage and isAudio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment