-
Notifications
You must be signed in to change notification settings - Fork 7
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
FED-1718 Callback ref null safety hint suggestor #275
Conversation
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on Slack: #support-infosec. |
# Conflicts: # lib/src/executables/null_safety_prep.dart
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.
|
||
@override | ||
Future<void> generatePatches() async { | ||
_log.info('Resolving ${context.relativePath}...'); |
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.
Should we make this something that doesn't produce stdout by default? Pretty noisy...
@aaronlademann-wf yeahhh I was talking to Greg about that edge case because if the ref is referenced multiple times it will keep adding the nullability hint and we decided that it wouldn't be worth the effort to make the codemod be internally aware of the changes it was making to reduce duplication since it's an easy manual fix and I think the migrator tool should work regardless of comment duplication |
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.
+1 / +10
Ran the codemod locally in admin_client
, xbrl-module
, w_table
, graph_ui
and doc_plat_client
. All expected changes look good, no unexpected changes or rtes while executing the codemod.
@Workiva/release-management-p |
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.
+1 from RM
Motivation
In React, callback refs are called with the component instance upon render, and can be called with null when the component unmounts or when the component providing the ref rerenders.
For example instance:
// @Dart=2.11
..ref = (FooComponent ref) {
// ref could be null!
_myRefVariable = ref;
}
As a result, callback refs should be typed as if the ref passed to them could be null.
The null safety migrator tool, however, seems to like to make these refs non-nullable.
To help with nullability inference during the null safety migration of over_react components, and to help prevent null errors afterwards, we need to develop codemods that adjust the typings of over_react callback refs.
Changes
Release Notes
Review
See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.
Please review:
QA Checklist
Merge Checklist
While we perform many automated checks before auto-merging, some manual checks are needed: