-
-
Notifications
You must be signed in to change notification settings - Fork 655
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
webview js: Fix type errors in handling null; mark strict-local.
We weren't actually checking that the messages we send to React from inside the webview were of the types we were assuming they were in the receiving code -- we had an `Object` type disabling the type-checker. And in fact, this was hiding a series of type errors! The inner code pulls various attributes' values off of the elements it looks at and sends them to the outer code, which blithely goes and assumes the results are strings -- but if the HTML is for some reason not as we expect it to be, they could be `null` or `undefined`. As a result, we'd end up going wrong in unpredictable ways, in code deep inside the app's logic. Instead, check our assumptions right at the edge, and if they fail then raise an exception so we drop the event and show an error banner. This is basically another instance of the "crunchy shell" pattern.
- Loading branch information
Showing
2 changed files
with
38 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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