Migrate the frontend codebase to TypeScript #7329
Labels
blocked
This can't continue until another issue or pull request is done
c/console
This is related to the Console
dependencies
Pull requests that update a dependency file
technical debt
Not necessarily broken, but could be done better/cleaner
ui/web
This is related to a web interface
Milestone
Summary
This issue proposes migrating our Console and Account applications from JavaScript to TypeScript. Utilizing TypeScript will provide significant benefits, including improved type safety, enhanced code maintainability, and a better developer experience, particularly as our applications continue to grow in complexity. Also, it enables us to be future proof for React 19.
Current Situation
Currently, both the Console and Account applications are entirely in JavaScript. While we utilize
propTypes
anddefaultProps
for rudimentary type checking. This approach is deprecated and set to be removed starting from React 19 Also, this approach is limited and doesn't offer the full benefits of static type checking. This can lead to potential runtime errors and negatively impacts code clarity and readability, especially when working with complex data structures and interactions between components and the Redux store.Why do we need this? Who uses it, and when?
Migrating to TypeScript will primarily benefit the developers working on these codebases. It offers several advantages:
Proposed Implementation
We will follow a gradual migration approach, gradually converting sections of the codebase to TypeScript to minimize disruption and ensure continuous integration and deployment:
Phase 1: Setting the Stage
npm install -D typescript @types/react @types/react-dom @types/react-redux
tsconfig.json
file for both Console and Account, initially setting thestrict
option tofalse
to allow for a smoother initial conversion..ts
and.tsx
).Phase 2: Picking the Low-Hanging Fruit
./components/tabs/index.js
./components/tabs/tab/index.js
./components/sidebar/switcher/index.js
./components/sidebar/search-button/index.js
./components/sidebar/section-label/index.js
./components/sidebar/side-footer/index.js
./components/sidebar/side-header/index.js
./components/sidebar/side-menu/item/link.js
./lib/to-input-date.js
./lib/filter-data-props.js
./lib/password/index.js
./lib/combine-refs.js
./lib/string-to-hash.js
./lib/host-from-url.js
./lib/debounce.js
./lib/get-by-path.js
./lib/capitalize-message.js
./lib/pipe.js
Phase 3: Tackling the Core
Phase 4: Increasing Type Strictness & Refactoring
tsconfig.json
to increase type strictness levels. This helps catch potential errors and enforce better coding practices.Specific Examples and Considerations
./constants/
define various constants and configurations. These can be easily converted using enums, type aliases, and interfaces.By following this phased approach, we can leverage TypeScript's strengths to significantly enhance the reliability, maintainability, and overall developer experience of our Console and Account applications.
Contributing
Validation
Code of Conduct
The text was updated successfully, but these errors were encountered: