From baacf1ef38b58c6f72c0edb215bc83658f636a4f Mon Sep 17 00:00:00 2001 From: Sydney Jodon Date: Tue, 15 Oct 2024 16:14:57 -0700 Subject: [PATCH 1/3] Update note about migrator companion codemod --- doc/null_safety/null_safe_migration.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/null_safety/null_safe_migration.md b/doc/null_safety/null_safe_migration.md index 7a8b4d6d7..f327e6bad 100644 --- a/doc/null_safety/null_safe_migration.md +++ b/doc/null_safety/null_safe_migration.md @@ -51,9 +51,11 @@ dart pub global run over_react_codemod:null_safety_migrator_companion --yes-to-a ``` This codemod will: -- Add nullability hints to props/state that are defaulted/initialized in class components. +- Add nullability hints to state mixin/class fields - These hints will cause defaulted/initialized values to be migrated as "late required". See our [prop requiredness and nullability](#prop-requiredness-and-nullability) docs for more details on whether you should keep them required following the migration. + - All non-initialized state fields will have optional nullable hints. +- Add nullable hints for callback ref types. #### Required props codemod From d47eb7989641da78a555d457a8c880a110babb5b Mon Sep 17 00:00:00 2001 From: Sydney Jodon Date: Wed, 23 Oct 2024 10:56:39 -0700 Subject: [PATCH 2/3] Add note about connect prop codemod --- doc/null_safety/null_safe_migration.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/null_safety/null_safe_migration.md b/doc/null_safety/null_safe_migration.md index f327e6bad..232909ed1 100644 --- a/doc/null_safety/null_safe_migration.md +++ b/doc/null_safety/null_safe_migration.md @@ -56,6 +56,7 @@ This codemod will: See our [prop requiredness and nullability](#prop-requiredness-and-nullability) docs for more details on whether you should keep them required following the migration. - All non-initialized state fields will have optional nullable hints. - Add nullable hints for callback ref types. +- Add annotations to disable required prop validation for `connect` props. See [`connect` required props migration case](#wrapper-and-connected-components-and-required-props) for more info. #### Required props codemod @@ -210,7 +211,7 @@ of the null safety and required props docs for instructions on how to handle the For connect, either: - Disable validation using the instructions linked above - - Note: for now, this must be done manually, but we'll be adding a codemod to help do this automatically for `connect`: https://github.com/Workiva/over_react_codemod/issues/295 + - Note: The [null safety migrator companion codemod](#companion-codemod) does this automatically for all `connect` props. - Refactor your component to instead utilize [OverReact Redux hooks](../over_react_redux_documentation.md#hooks), which avoid this problem by accessing store data and dispatchers directly in the component as opposed to passing it in via props. From 7a6eec812c0ac494faab2802dcd2f4a345153d17 Mon Sep 17 00:00:00 2001 From: Sydney Jodon Date: Thu, 24 Oct 2024 14:19:54 -0700 Subject: [PATCH 3/3] Address feedback --- doc/null_safety/null_safe_migration.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/null_safety/null_safe_migration.md b/doc/null_safety/null_safe_migration.md index 232909ed1..27b649e2b 100644 --- a/doc/null_safety/null_safe_migration.md +++ b/doc/null_safety/null_safe_migration.md @@ -52,7 +52,7 @@ dart pub global run over_react_codemod:null_safety_migrator_companion --yes-to-a This codemod will: - Add nullability hints to state mixin/class fields - - These hints will cause defaulted/initialized values to be migrated as "late required". + - These hints will cause defaulted/initialized values to be migrated as "late required" (the same thing is done for props in the [required props codemod](#required-props-codemod)). See our [prop requiredness and nullability](#prop-requiredness-and-nullability) docs for more details on whether you should keep them required following the migration. - All non-initialized state fields will have optional nullable hints. - Add nullable hints for callback ref types. @@ -66,7 +66,9 @@ as a separate commit before proceeding with the rest of the migration. This is a two-step process involving two sub-commands: 1. `null_safety_required_props collect` - Collects requiredness data for all OverReact props based on usages in the specified packages and all their transitive dependencies. -1. `null_safety_required_props codemod` - Adds null safety migrator hints to OverReact props using prop requiredness data from 'collect' command. +1. `null_safety_required_props codemod` - Adds null safety migrator hints to OverReact props taking into account: + 1. Prop requiredness data from the 'collect' command. + 1. If the prop has a default in `defaultProps`, it will get "late required" hints. Start with the `collect` command, following its help output for instructions: ```shell