Last active
August 14, 2022 22:30
-
-
Save bennycode/7cacbf64ddeaf6395c16927375331d0f to your computer and use it in GitHub Desktop.
Never Type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface StreamResponse { | |
status: StreamStatus; | |
} | |
enum StreamStatus { | |
IDLE, | |
ONLINE, | |
OFFLINE, | |
} | |
function handleResponse(response: StreamResponse): void { | |
switch (response.status) { | |
case StreamStatus.ONLINE: | |
console.log('You are online.'); | |
break; | |
case StreamStatus.OFFLINE: | |
console.log('You are offline.'); | |
break; | |
default: | |
const status: never = response.status; | |
throw new Error(`Unknown status "${status}"!`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment