refactor: convert status_bar to TypeScript
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
- Convert import and exports from CommonJS to ES modules
- Specify function input types and class properties types
- Add non-null assertions and optional chaining
- non-null assertions (
!
) are used when a variable can benull
orundefined
, 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.
- non-null assertions (
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