Skip to content
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

More strict null checks work #8340

Merged
merged 72 commits into from
Apr 25, 2024
Merged

Conversation

grahamlangford
Copy link
Collaborator

What does this PR do?

  • Follows untangling previous dependency cycles

Checklist

  • Designate a primary reviewer @BLoe

Copy link

codecov bot commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 69.04762% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 73.52%. Comparing base (1b2a1d9) to head (58d9292).

Files Patch % Lines
src/background/installer.ts 33.33% 6 Missing ⚠️
src/background/telemetry.ts 0.00% 3 Missing ⚠️
src/contentScript/pageEditor/selectElement.ts 83.33% 2 Missing ⚠️
src/extensionConsole/pages/UpdateBanner.tsx 50.00% 1 Missing ⚠️
src/store/extensionsMigrations.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8340      +/-   ##
==========================================
+ Coverage   73.50%   73.52%   +0.02%     
==========================================
  Files        1330     1330              
  Lines       41131    41142      +11     
  Branches     7643     7657      +14     
==========================================
+ Hits        30233    30250      +17     
+ Misses      10898    10892       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +94 to +97
// At least one must match, otherwise userSelectElement would have thrown
activeRoot =
rootElements?.find((rootElement) => rootElement.contains(element)) ??
null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think the comment here means we could safely use assertNotNullish()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is find can always return undefined. I think this is the simplest from a typing. Other option would be to use !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't work?

Suggested change
// At least one must match, otherwise userSelectElement would have thrown
activeRoot =
rootElements?.find((rootElement) => rootElement.contains(element)) ??
null;
activeRoot = rootElements?.find((rootElement) => rootElement.contains(element));
// At least one must match, otherwise userSelectElement would have thrown
assertNotNullish(activeRoot);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, cause then I would have to change the typing of activeRoot to allow undefined

Copy link

No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack.

Do not edit this comment manually.

@grahamlangford grahamlangford enabled auto-merge (squash) April 25, 2024 19:44
@grahamlangford grahamlangford merged commit 44a3b1a into main Apr 25, 2024
22 checks passed
@grahamlangford grahamlangford deleted the strictNullChecks-dep-cycle-2 branch April 25, 2024 19:58
@twschiller twschiller added this to the 1.8.13 milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants