We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expectNever()
class UnsupportedValueError extends Error { constructor(value: never, message = `Unsupported value: ${value}`) { super(message) } } // Usage example: enum Color {Red, Green} function colorToString(color: Color) { switch (color) { case Color.Red: return 'RED'; case Color.Green: return 'GREEN'; default: throw new UnsupportedValueError(color); } }
I find this code a little more self-explanatory. Compare:
function colorToString(color: Color) { switch (color) { case Color.Red: return 'RED'; case Color.Green: return 'GREEN'; default: return expectNever(color); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I find this code a little more self-explanatory. Compare:
The text was updated successfully, but these errors were encountered: