Skip to content

refactor: convert status_bar to TypeScript

Tomas Vik requested to merge 212-convert-status-bar-to-ts into main

This MR migrates openers and status_bar modules to TypeScript in preparation for #212 (closed) which will change the way we fetch updates from the API.

JS files can depend on TS, but not the other way around. That's why we had to migrate openers as well. openers was the only JS module that status_bar depended on.

Key steps when migrating to TS

  1. Convert import and exports from CommonJS to ES modules
  2. Specify function input types and class properties types
  3. Add non-null assertions and optional chaining
    • non-null assertions (!) are used when a variable can be null or undefined, but we want to force TS to think that it is always truthy. This is not a good form, but it is a good start without rewriting half of the code. It causes eslint warnings
    • in the refactored code, we had to add non-null assertions to workspaceFolder and API responses. I've tested the code locally and the non-null assertions are now hiding existing bugs (JS didn't warn us, but TS now does). We should remove the assertions as quickly as possible.

How to review the MR

The MR is split into meaningful commits. Almost all of these commits have descriptive multiline messages explaining the changes. I recommend reviewing the MR commit-by-commit.

Related to #212 (closed)

Edited by Tomas Vik

Merge request reports

Loading