-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref: Use optional chaining where possible #14954
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
Conversation
size-limit report 📦
|
23e3a85
to
aaae4ab
Compare
@@ -57,7 +57,7 @@ export function reactRouterV3BrowserTracingIntegration( | |||
afterAllSetup(client) { | |||
integration.afterAllSetup(client); | |||
|
|||
if (instrumentPageLoad && WINDOW && WINDOW.location) { | |||
if (instrumentPageLoad && WINDOW.location) { |
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.
ah ok, I'm seeing there's a pattern where we no longer check on the definedness of WINDOW
. I guess that's alright then? We should always get some kind of global object 🤔
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.
yeah, I think some global object will always be there, so it should not be necessary to check this - or can we think of a scenario where this is 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.
As long as we don't assume any browser-specific attributes to be present (which we don't in these changes) I think we're good!
I would have expected the bundle size decrease to be a bit larger but every lost byte is a good byte 😅 |
Co-authored-by: Lukas Stracke <[email protected]>
Yeah, had the same thought 😅 |
Is there a prefer optional chaining lint rule we could turn on? |
There is a rule actually, I will make a follow up PR adding this! |
This PR updates our code to use optional chaining, where possible.
This was mostly search-and-replace by
xx && xx.
regex, so there may def. be some remaining places, but this should cover a good amount of usage.