Migration to TypeScript #135
Notifications
Total Time Spent: 5 hours 1 minute
jakob.scheid
5 hours 1 minute
No due date set.
Dependencies
No dependencies set.
Reference: Seekra/frontend#135
Reference in new issue
Block a user
Migrate JavaScript codebase to TypeScript
The entire JavaScript codebase should be migrated to TypeScript to improve the long-term maintainability, scalability, and reliability of the frontend.
Motivation
As the codebase grows, JavaScript's dynamic type system makes it increasingly difficult to reliably understand and maintain the relationships between different parts of the application. Function parameters, return values, object structures, API responses, component properties, and application state can change without the tooling being able to detect all affected usages.
TypeScript provides a static type system on top of JavaScript. This allows many classes of errors to be detected during development and CI rather than only when the affected code is executed. For example, invalid function arguments, incompatible assignments, missing object properties, and incorrect return types can be detected before the application is run.
Type definitions also make the codebase easier to understand and refactor. When an interface, API response, or shared data structure changes, TypeScript can identify many locations that need to be updated. This is particularly valuable as the project grows and more components and features depend on the same data structures.
TypeScript also provides significantly better editor support, including reliable autocompletion, navigation, refactoring, and inline documentation. This reduces the amount of implicit knowledge required to work on the codebase and makes it easier for additional developers to contribute.
What happens if we do not migrate?
If the project remains JavaScript-only, the increasing size and complexity of the codebase will make type-related problems progressively harder to detect and prevent.
Changes to shared data structures may silently break consumers that are not covered by the relevant runtime paths or tests. Developers will also have to rely more heavily on documentation, conventions, tests, and manual verification to determine what types of values a function or component expects.
As the project continues to grow, this can make refactoring more risky and time-consuming. A change that should be straightforward may require manually searching the codebase for all affected usages, while some incompatibilities may only become apparent when a particular code path is executed.
This does not mean that JavaScript is inherently unsuitable for large applications, but retaining a dynamically typed codebase would make the project increasingly dependent on runtime checks and tests for problems that could otherwise be detected statically.
Goal
The project and the tooling used is correctly configured to use TypeScript so that the frontend can still be built and run in development server as usual.
All existing JavaScript source code has been migrated to TypeScript. This establishes TypeScript as the standard language for future frontend development.
The existing functionality and behavior of the application is preserved; the user is not affected by the migration. Appropriate TypeScript configuration and tooling is also included so that type checking is performed as part of the development and CI workflow.
After the migration, newly added frontend code should be written in TypeScript rather than JavaScript.
Migrate to TypeScriptto Migration to TypeScript