Migrate the extension to TypeScript
Problem to solve
The VS Code extension ecosystem is widely using TypeScript (TS), and VS Code itself is implemented in TS and exposes types for all its APIs. This issue is tracking the decision for migrating the codebase to TypeScript.
🍏 Benefits of using TS
- Since there are no tests, the static type checking might help at the beginning with discovering bugs.
- Future refactoring would be made simpler by the TS language support.
- The extension implementation would be consistent with the ecosystem.
- Community contributors can work on the extension without detailed knowledge of the codebase thanks to interface lookup and autocompletion.
🍎 Drawbacks of using TS
- Effort connected with migration. That's mainly the following two parts:
- Reviewing the !53 (closed) and potentially changing the TS implementation before merging
- Manual testing and fixing any bugs that should come up from the rewrite.
- The codebase will have a different syntax from what GitLab FE engineers are used to.
- Compilation time is a drawback for Large TS codebases, it's not going to be an issue for the extension with its less than 10k lines of code.
Proposal
We need to decide as a team if the benefits outweigh the drawbacks. I propose we'll do it in a way of a RFC period of one week when we give the team chance to express their concerns or ideas.
If there are no serious concerns and we decide to proceed, we will review and merge the !53 (closed) in two distinct MRs.
The codebase is clearly separated in two:
- the main extension lives in the project root
/
- the experimental webview1 lives in
/src/webview
and is compiled and exported in/src/webview/dist
.
We would separate the !53 (closed) changes related to /src/webview
and review and merge them first. That is a less risky change since the webview is experimental.
After that, we would review and merge the changes to the main extension.
Further details
You can have a look at the open MR from @massimeddu !53 (closed) to get a sense how would the initial TS version of the codebase look like.
Links / references
- Discussion about using static type checking in the GitLab codebase: gitlab#19973 (moved)