You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following components don't yet have type information, and should be converted from .jsx to .tsx files. The props documentation should be moved from the propTypes data to the TypeScript Props interface. See this example. The defaultProps should be removed and any defaults (other than undefined) should be specified as function parameters.
This will eliminate our usage of deprecated APIs (propTypes, defaultProps), clear the way for upgrading to React 19, allow developers using Paragon to catch errors much more easily (i.e. at build time), and eliminate console warnings about defaultProps still being used.
Be sure to update src/index.ts as part of each PR, to remove the // @ts-ignore directive and to move the component from the "things that don't have types" section to the "things that have types" section (preserve alphabetical order).
Please prefer smaller PRs with just 1-3 components per PR, to help keep review effort reasonable.
Focus in particular on checking the props documentation in the docs site (npm run start) to ensure that our gatsby docs generator is correctly pulling in the right documentation for each property that the component accepts.
When you open a PR, a new "deploy preview" site will be created that makes it easy to compare the docs page with your changes to the previous version published at https://paragon-openedx.netlify.app/
🤔 Note that components using forwardRef require a very specific syntax in order for the props documentation to be detected correctly:
❌ Won't work (props documentation will be missing)
✅ Works (props will be documented)
For components that extend Bootstrap components, it's unfortunately necessary to re-declare all of the props from the Bootstrap component, or else they won't appear in the documentation on our docs site. If the props are standard HTML props like role or onClick though, you don't need to document them separately - see #3742 for an example.
List of components
Because there are a lot of components here, I haven't created subtasks for each of these yet. Also, these have been sorted by usage so we can convert the most important ones first:
The following components don't yet have type information, and should be converted from .jsx to .tsx files. The props documentation should be moved from the
propTypesdata to the TypeScriptPropsinterface. See this example. ThedefaultPropsshould be removed and any defaults (other thanundefined) should be specified as function parameters.This will eliminate our usage of deprecated APIs (
propTypes,defaultProps), clear the way for upgrading to React 19, allow developers using Paragon to catch errors much more easily (i.e. at build time), and eliminate console warnings aboutdefaultPropsstill being used.Related issues: #3744 #3043 #2404 and this PR with some type definitions: #2566
Details and advice
The following codemods may be helpful in automating this work: propTypes -> TS codemod, defaultProps codemod
Be sure to update
src/index.tsas part of each PR, to remove the// @ts-ignoredirective and to move the component from the "things that don't have types" section to the "things that have types" section (preserve alphabetical order).Please prefer smaller PRs with just 1-3 components per PR, to help keep review effort reasonable.
npm run start) to ensure that our gatsby docs generator is correctly pulling in the right documentation for each property that the component accepts.When you open a PR, a new "deploy preview" site will be created that makes it easy to compare the docs page with your changes to the previous version published at https://paragon-openedx.netlify.app/
🤔 Note that components using
forwardRefrequire a very specific syntax in order for the props documentation to be detected correctly:For components that extend Bootstrap components, it's unfortunately necessary to re-declare all of the props from the Bootstrap component, or else they won't appear in the documentation on our docs site. If the props are standard HTML props like
roleoronClickthough, you don't need to document them separately - see #3742 for an example.List of components
Because there are a lot of components here, I haven't created subtasks for each of these yet. Also, these have been sorted by usage so we can convert the most important ones first:
Stack- 204 uses - Transform <CardBody>, <CardContext>, <CardDivider>, <CardGrid> and <Stack> to typescript #3820Skeleton- 178 usesActionRow- 174 uses - Transform <Annotation>, <ActionRow>, <Avatar>, <AvatarButton> to typescript #3801Card- 145 uses - some parts done in Transform <CardBody>, <CardContext>, <CardDivider>, <CardGrid> and <Stack> to typescript #3820Badge- 114 uses - Transform <Badge>, <Breadcrumb>, <BreadcrumbLink>, <CardCarouselTitle> and <CardCarouselSubtitle> to typescript #3807StatefulButton- 112 uses - feat: convert StatefulButton to TypeScript #4138DataTable- 78 usesCardView- 52 usesTableFooter- 2 usesCheckboxFilter- 1 useDropdownFilter- 0 usesMultiSelectDropdownFilter- 0 usesTextFilter- 0 usesTableHeaderCell- 0 usesTableCell- 0 usesTableFilters- 0 usesTableHeader- 0 usesTableRow- 0 usesTablePagination- 0 usesTablePaginationMinimal- 0 usesDataTableContext- 0 usesBulkActions- 0 usesTableControlBar- 0 usesSpinner- 76 uses - refactor: convert <Spinner> to TypeScript #3714Form- 70 usesFormControlFeedbackFormTextFormControlDecoratorGroupFormRadioFormRadioSetFormRadioSetContextFormAutosuggestFormAutosuggestOptionFormCheckboxFormSwitchFormCheckboxSetFormSwitchSetFormCheckboxSetContextuseCheckboxSetValuesCollapsible- 62 uses (@rodmgwgu )Tabs,Tab, etc. - 58 uses - Transform <TableCell>, <TableHeaderCell>, <MenuItem>, <Menu>, <PageBanner> and <Tab> to typescript #3831Image,Figure- 50 usesDropdown- 46 usesMailtoLink- 36 uses - refactor: MailtoLink component migrated to TS #4140AlertModal- 30 uses (@brian-smith-tcril )TransitionReplace- 30 usesModalPopup- 29 uses - feat: add prop to set noIsolation prop for modal popup #3777Breadcrumb- 26 uses - Transform <Badge>, <Breadcrumb>, <BreadcrumbLink>, <CardCarouselTitle> and <CardCarouselSubtitle> to typescript #3807Truncate- 23 uses. Needs total rewrite.PageBanner- 22 uses - Transform <TableCell>, <TableHeaderCell>, <MenuItem>, <Menu>, <PageBanner> and <Tab> to typescript #3831ProgressBar,ProgressBarAnnotated- 18 uses - feat: convert ProgressBar component to TypeScript #4139SearchField,SearchFieldAdvanced- 18 usesStandardModal- 18 usesLayout,Col,Row- 16 usesPagination- 16 usesPopover- 13 uses (@jacobo-dominguez-wgu )Nav,NavDropdown,NavItem,NavLink- 12 usesAvatarButton- 10 uses - Transform <Annotation>, <ActionRow>, <Avatar>, <AvatarButton> to typescript #3801Avatar- 8 uses - Transform <Annotation>, <ActionRow>, <Avatar>, <AvatarButton> to typescript #3801Dropzone- 8 usesFullscreenModal- 8 usesSelectableBox- 8 usesStepper- 7 uses (@tonybusa )Menu- 3 uses - Transform <TableCell>, <TableHeaderCell>, <MenuItem>, <Menu>, <PageBanner> and <Tab> to typescript #3831MenuItem- 10 uses - Transform <TableCell>, <TableHeaderCell>, <MenuItem>, <Menu>, <PageBanner> and <Tab> to typescript #3831Navbar- 3 usesProductTour- 3 usesMarketingModal- 2 usesSelectMenu- 2 usesSheet- 2 usesScrollable- 2 usesModalCloseButton- 1 use (@diana-villalvazo-wgu )Not sure if these are worth converting, or deprecating? They are not used in any Open edX MFEs, but may be used outside of Open edX?
Annotation- 0 usesCarousel- 0 usesColorPicker- 0 usesIconButtonToggle- 0 usesOverflowScrolletc. - 0 usesPopperElement- 0 usesSticky- 0 usesUndocumented passthrough components (very easy to convert - just rename the
.jsxto.tsx)CloseButton(undocumented?) - ?? uses - Transform <Annotation>, <ActionRow>, <Avatar>, <AvatarButton> to typescript #3801Collapse(undocumented?) - ?? uses - Transform <Annotation>, <ActionRow>, <Avatar>, <AvatarButton> to typescript #3801Fade(undocumented?) - ?? uses - Transform <Annotation>, <ActionRow>, <Avatar>, <AvatarButton> to typescript #3801Media(undocumented?) - ?? uses - Transform <Annotation>, <ActionRow>, <Avatar>, <AvatarButton> to typescript #3801ResponsiveEmbed(undocumented?) - ?? uses - Transform <Annotation>, <ActionRow>, <Avatar>, <AvatarButton> to typescript #3801ToggleButton(undocumented?) - ?? uses - Transform <Annotation>, <ActionRow>, <Avatar>, <AvatarButton> to typescript #3801ValidationMessage(undocumented?) - ?? uses - Transform <Annotation>, <ActionRow>, <Avatar>, <AvatarButton> to typescript #3801Other things:
messages.jsfiles (simply rename tomessages.ts) - Transform messages into typescript files #3798asInputVariant