Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Handling console.log(null) (#1520)
## Please verify the following: - [x] `yarn build-and-test:local` passes - [ ] ~I have added tests for any new features, if relevant!~ - [ ] ~`README.md` (or relevant documentation) has been updated with your changes~ ## Describe your PR Fixes #1517 where calling `console.log` with `null` resulted in a blank screen. Now the comments around the function say that it only handles `string`, `object`, `number`, and `boolean`; however, the function takes a `message` of type `any`. Seems like we could narrow that down a bit. I've checked with all of the possible return values for `typeof` and documented that in the code. The reason the bug existed is because `typeof null` results in `object`. The code -- nor many people-- were expecting that. Here's the reference to the docs as to why: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null It appears that we do some things to not return functions as strings and we don't handle `Symbol`. Not sure if that's a requirement based on what the comments around the function say that it should accept as a message type.⚠️ I'm not sure why the `getPreview` function returned just the raw message if we didn't discern what type it was. That seems like a bug. If someone has context as to why that was the case, I'd love to understand why. ## Screenshot This is what it looks like now: <img width="598" alt="image" src="https://github.com/user-attachments/assets/93c937eb-04bb-47c1-a219-1c751379924f"> Here's another case where we didn't handle `null` correctly and now we do: <img width="775" alt="image" src="https://github.com/user-attachments/assets/83184221-0a79-407d-80cf-2aaefa7d5e55"> Happy Debugging 😎
- Loading branch information