Fix useBoxMetrics not accepting ref objects with an initial null value#945
Merged
Conversation
Collaborator
|
The docs still lists the |
Contributor
Author
|
@sindresorhus Thanks. Updated the docs as well now. |
useBoxMetric not accepting ref objects with an initial null valueuseBoxMetrics not accepting ref objects with an initial null value
Contributor
Author
|
Hi, sorry, I haven't contributed to open source projects much, so I'm not familiar with the process. Is there anything else I need to do to complete this merge request? |
Merged
6 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request hopes to change the current behaviours below to the expected behaviours.
Current Behaviours
With
complierOptions.strictNullChecks: trueset intsconfig.json, compilation with the below code in the project always fails due touseBoxMetricsonly acceptingRefObject<DOMElement>and not alsoRefObject<DOMElement | null>.Further, VSCode highlights a type error regardless of the compiler options sets:

Expected Behaviours
complierOptions.strictNullChecks: trueis set intsconfig.json, the code above shouldn't cause compilation to fail.useBoxMetricsshould be able to acceptRefObject<DOMElement | null>since it's common for a ref object (especially one that will be passed to a DOM node's ref attribute) to be created with an initialnullvalue.