Skip to content

Removing propTypes from core components #21342

Closed
@elicwhite

Description

@elicwhite

We have been using Flow for our components for a long while and have enjoyed much stricter type safety, enabling us to validate our code at compile time instead of with propTypes at runtime. We want to replace the remaining callsites of propTypes with Flow and deprecate the propType shapes exposed by React Native core. To do this, we need your help!

This is step 1 of our multi step goal. Step 2 can be found here.

There are two classes of things that need to happen to complete this work. The first step is removing references from propTypes in our core components. The following are the individual files that need to be converted / updated. Each file should be converted in its own PR and each file is about the size of a good first issue to learn and get familiar with a part of the React Native codebase. If you’d like to convert one, pick one from the list, comment on this issue that you are interested in converting it, and follow the tips in @empyrical's comment for help successfully updating that file.

Remove callsites from components:

  • Libraries/Components/Button.js -> Delete PropTypes
  • MaskedViewIOS.ios.js -> Delete PropTypes
  • Picker/Picker.js -> Delete PropTypes
  • PickerAndroid.android.js -> Delete PropTypes
  • StaticRenderer.js -> Delete PropTypes
  • StatusBar/StatusBar.js -> Delete PropTypes
  • TabBarIOS/TabBarIOS.ios.js -> Delete PropTypes
  • TabBarIOS/TabBarItemIOS.ios.js -> Convert to Flow Types
  • ViewPagerAndroid.android.js -> Delete PropTypes
  • IncrementalPresenter.js -> Delete PropTypes, leave contextTypes
  • SwipeableFlatList.js -> Delete PropTypes
  • SwipeableListView.js -> Delete PropTypes
  • SwipeableQuickActions.js -> DeletePropTypes (style changed to ViewStyleProp)
  • ElementProperties.js -> Delete PropTypes
  • InspectorPanel -> Delete PropTypes
  • InspectorOverlay.js -> Delete PropTypes
  • SnapshotViewIOS.ios.js -> Delete PropTypes
  • LinkingExample.js -> Convert to Flow Types
  • RNTesterBlock.js -> Delete PropTypes, strengthen Flow Types
  • RNTesterButton.js -> Delete PropTypes
  • RNTesterPage.js -> Delete PropTypes
  • Modal.js -> Convert to Flow Types, slightly bigger task
  • IntegrationTestHarnessTest
  • InputAccessoryView -> no propTypes, but flow types need to get cleaned up

Move and Rename custom propType definitions

For these, I think we should create a new folder, react-native/Libraries/DeprecatedPropTypes. Many of these files have both the Flow definition and the propTypes definition. "Split" means split these into two files, in the example of EdgeInsetsPropType it would mean having an EdgeInsetsPropType.js file that contains the commented flow types, and a DeprecatedEdgeInsetsPropType.js file inside the DeprecatedPropTypes folder. Eventually that folder will become the source for the new repo that we move out.

  • Create a new folder at react-native/Libraries/DeprecatedPropTypes (should be done as part of one of the other tasks)
  • DeprecatedViewPropTypes -> Move, comments to ViewPropTypes
  • EdgeInsetsPropType -> Split
  • PlatformViewPropTypes -> Move
  • TVViewPropTypes -> Split
  • StyleSheetPropType -> Move
  • createStrictShapeTypeChecker -> Move
  • ViewAccessibility -> Split (in progress)
  • ViewStylePropTypes -> Move
  • ImageProps -> Split (in progress)
  • ImageSourcePropType -> Move
  • ImageStylePropTypes -> Move
  • TextPropTypes -> Move
  • ColorPropType -> Move
  • LayoutPropTypes -> Move, comments to StyleSheetTypes
  • ShadowPropTypesIOS -> Move, comments to StyleSheetTypes
  • TransformPropTypes -> Move, comments to StyleSheetTypes
  • PointPropType -> Split

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueInterested in collaborating? Take a stab at fixing one of these issues.Help Wanted :octocat:Issues ideal for external contributors.JavaScriptResolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions