explorer icon indicating copy to clipboard operation
explorer copied to clipboard

Proposal: Migrate to TypeScript

Open chidexebere opened this issue 2 years ago • 2 comments

Reasons

I have gone through a reasonable amount of the codebase and I have seen that there is a need to improve the development experience and code quality. TypeScript is better suited for building and managing large-scale applications with multiple teams.

  • It checks the code for errors and warnings before you run it.
  • It static typing feature will reduce the number of errors at build time; hence better developer experience.
  • There will be no need for prop-types, type checking feature will take care of this.
  • It makes code easier to read, maintain, and debug, and can also help reduce the risk of security vulnerabilities.
  • It provides extra tooling and features like interfaces, classes, namespaces, generics, etc.

Proposal

  • Migration can be done in parts since existing JavaScript code will still run in TypeScript.
  • TypeScript code must not be strictly typed as the migration starts. Changes can be made as it progresses. For example, tests can still be left as JavaScript code.

chidexebere avatar Apr 17 '23 07:04 chidexebere

Ah yes this does indeed sound like a very good idea. As a matter of fact for newer projects we have started building them in typescript from the beginning.

If you would like to take a stab at starting the migration to typescript that would be fantastic!

hellais avatar Apr 19 '23 13:04 hellais

I wanted to share my plan for the migration.

  1. Set up TypeScript: Install TypeScript and Create a tsconfig.json file to configure TypeScript.
  2. Rename the .js files to .tsx. I will start with the components folder and move to others.
  3. Update dependencies: Some third-party libraries have TypeScript typings available. I will Install these typings (e.g., @types/package-name). If typings are not available, I may need to create custom type definitions or leverage TypeScript's any type for those libraries.
  4. Type annotations and interfaces: Gradually add type annotations to the codebase using interfaces or type aliases.
  5. Compile and test: Run tests to ensure the migration hasn't introduced any regressions or bugs.
  6. Refactor and optimize.
  7. Iterate and repeat from step 2 as I move from one folder to another. Push code with migration done per folder.

chidexebere avatar May 18 '23 23:05 chidexebere