-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
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
Add strict type-checks that most switch statements cover all cases #477
Conversation
Deployed to Cloudflare Pages
|
return ( | ||
<div> | ||
<div>{eventName}</div> | ||
<pre>{JSON.stringify(event, null, ' ')}</pre> | ||
</div> | ||
) | ||
default: | ||
throw new ExhaustedTypeError('Unexpected event type', event.type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not happy with throwing an error (and hence breaking the whole page) just because we see something we don't recognize. I thing we should also have an exhaustedTypeWarning()
function, which just uses console.warn()
, and use that in the milder cases like this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converted to warnings in production and errors in development
1c815e8
to
4c71566
Compare
default: | ||
exhaustedTypeWarning('Unexpected layer', layer) | ||
throw new AppError(AppErrors.UnsupportedLayer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are throwing two exceptions on quick succession. (At least in PROD mode.) Are they both necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, unless we introduce more fallbacks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed, LGTM (except one comment)
But only print a warning if encountered in production.
No description provided.