Tracking issue: Convert components to TypeScript
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 140
- Forks
- 100
- Avg merge
- 1h 3m
- Merged PRs (30d)
- 30
Description
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.
Related issues: https://github.com/openedx/paragon/issues/3744 https://github.com/openedx/paragon/issues/3043 https://github.com/openedx/paragon/issues/2404 and this PR with some type definitions: https://github.com/openedx/paragon/pull/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.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 https://github.com/openedx/paragon/pull/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 - https://github.com/openedx/paragon/pull/3820 -
Skeleton- 178 uses -
ActionRow- 174 uses - https://github.com/openedx/paragon/pull/3801 -
Card- 145 uses - some parts done in https://github.com/openedx/paragon/pull/3820 -
Badge- 114 uses - https://github.com/openedx/paragon/pull/3807 -
StatefulButton- 112 uses - https://github.com/openedx/paragon/pull/4138 -
DataTable- 78 uses-
CardView- 52 uses -
TableFooter- 2 uses -
CheckboxFilter- 1 use -
DropdownFilter- 0 uses ⚠️ -
MultiSelectDropdownFilter- 0 uses ⚠️ -
TextFilter- 0 uses ⚠️ -
TableHeaderCell- 0 uses ⚠️ - https://github.com/openedx/paragon/pull/3831 -
TableCell- 0 uses ⚠️ - https://github.com/openedx/paragon/pull/3831 -
TableFilters- 0 uses ⚠️ -
TableHeader- 0 uses ⚠️ -
TableRow- 0 uses ⚠️ -
TablePagination- 0 uses ⚠️ -
TablePaginationMinimal- 0 uses ⚠️ -
DataTableContext- 0 uses ⚠️ -
BulkActions- 0 uses ⚠️ -
TableControlBar- 0 uses ⚠️
-
-
Spinner- 76 uses - https://github.com/openedx/paragon/pull/3714 -
Form- 70 uses-
FormControlFeedback -
FormText -
FormControlDecoratorGroup -
FormRadio -
FormRadioSet -
FormRadioSetContext -
FormAutosuggest -
FormAutosuggestOption -
FormCheckbox -
FormSwitch -
FormCheckboxSet -
FormSwitchSet -
FormCheckboxSetContext -
useCheckboxSetValues
-
-
Collapsible- 62 uses (@rodmgwgu ) -
Tabs,Tab, etc. - 58 uses - https://github.com/openedx/paragon/pull/3831 -
Image,Figure- 50 uses -
Dropdown- 46 uses -
MailtoLink- 36 uses - https://github.com/openedx/paragon/pull/4140 -
AlertModal- 30 uses (@brian-smith-tcril ) -
TransitionReplace- 30 uses -
ModalPopup- 29 uses - https://github.com/openedx/paragon/pull/3777 -
Breadcrumb- 26 uses - https://github.com/openedx/paragon/pull/3807 -
Truncate- 23 uses. Needs total rewrite. -
PageBanner- 22 uses - https://github.com/openedx/paragon/pull/3831 -
ProgressBar,ProgressBarAnnotated- 18 uses - https://github.com/openedx/paragon/pull/4139 -
SearchField,SearchFieldAdvanced- 18 uses -
StandardModal- 18 uses -
Layout,Col,Row- 16 uses -
Pagination- 16 uses -
Popover- 13 uses (@jacobo-dominguez-wgu ) -
Nav,NavDropdown,NavItem,NavLink- 12 uses -
AvatarButton- 10 uses - https://github.com/openedx/paragon/pull/3801 -
Avatar- 8 uses - https://github.com/openedx/paragon/pull/3801 -
Dropzone- 8 uses -
FullscreenModal- 8 uses -
SelectableBox- 8 uses -
Stepper- 7 uses (@tonybusa ) -
Menu- 3 uses - https://github.com/openedx/paragon/pull/3831-
MenuItem- 10 uses - https://github.com/openedx/paragon/pull/3831
-
-
Navbar- 3 uses -
ProductTour- 3 uses -
MarketingModal- 2 uses -
SelectMenu- 2 uses -
Sheet- 2 uses -
Scrollable- 2 uses -
ModalCloseButton- 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 uses ⚠️ - https://github.com/openedx/paragon/pull/3801 -
Carousel- 0 uses ⚠️ -
ColorPicker- 0 uses ⚠️ -
IconButtonToggle- 0 uses ⚠️ -
OverflowScrolletc. - 0 uses ⚠️ -
PopperElement- 0 uses ⚠️ - https://github.com/openedx/paragon/pull/3777 -
Sticky- 0 uses ⚠️
Undocumented passthrough components (very easy to convert - just rename the .jsx to .tsx)
-
CloseButton(undocumented?) - ?? uses - https://github.com/openedx/paragon/pull/3801 -
Collapse(undocumented?) - ?? uses - https://github.com/openedx/paragon/pull/3801 -
Fade(undocumented?) - ?? uses - https://github.com/openedx/paragon/pull/3801 -
Media(undocumented?) - ?? uses - https://github.com/openedx/paragon/pull/3801 -
ResponsiveEmbed(undocumented?) - ?? uses - https://github.com/openedx/paragon/pull/3801 -
ToggleButton(undocumented?) - ?? uses - https://github.com/openedx/paragon/pull/3801 -
ValidationMessage(undocumented?) - ?? uses - https://github.com/openedx/paragon/pull/3801
Other things:
- all
messages.jsfiles (simply rename tomessages.ts) - https://github.com/openedx/paragon/pull/3798 -
asInput -
Variant
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Choose one unchecked component and start by comparing its JSX implementation with the example in pull request 3714. Update src/index.ts as described, then run npm run start and inspect the component's props documentation. Done means converting one to three components and verifying their generated documentation against the deploy preview.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100