Been working on this off and on for over two months. It's a project dashboard plugin that allows you to organize workspace for easy launching and switching. It was a lot of fun to figure this out, given that Code is Electron there was a lot I had to learn about things like NPM and TypeScript. I'm sold on TypeScript now though. The most important distinction (to me) is that this one supports remote development, without requiring it be installed on the remote servers. So many extensions are wrongly classified and have no business being installed remotely when they are just UI work.
The backend, the parts that manage updating your config files as well as most of the logic, was written in strict TypeScript - meaning I tried really hard to never cheat by telling TS to ignore things, or using "any" types where they make no sense. This then transpiles into a cluster of normal Javascript and that is what eventually gets executed.
The frontend, all the things you can actually see in the Dashboard tab, was written as straight ES6 - it does not transpile, the frontend runs the exact code that came out of my fingertips, but takes advantage of the better ES6 features like allowing you to define proper classes, and the module system. I am still very tempted to rewrite the frontend in TypeScript as well, but getting 1 project to output two different styles of modules seems to be a bit of a bitch. The backend needs the CommonJS node format, and the frontend needs the ES6 format as I am unwilling to include things like RequireJS and use require() instead of import. Given that I have little experience in this ecosystem for all I know, its actually easy to do and I am just blind.
Another thing is that this extension contains a line of code that is probably my new favourite.
this[key as keyof this] = this.api.get(key) as (typeof self[(keyof this)]);
It exists because of a loop where I wanted to copy values from one object storage to another object storage after validating that its even a thing on the destination. The best part is the self. This alias hack was required or else the typescript compiler would lose its mind! Sometimes it would compile... sometimes it would not!
class Config {
// ....
public fillFromEditorConfig():
void {
let self = this;
// in this instance this self is quite specific because vsocde would
// claim everything was fine, but manually running the compiler
// bombed saying cannot find name this. even though for a while it
// was working. but then this alias hack... whatever my dudes.
for(const key of this.keepers) {
if(key === 'database')
continue;
if(!this.api.has(key))
continue;
this[key as keyof this] = this.api.get(key) as (typeof self[(keyof this)]);
}
return;
};
// ...
}
Anyway, hope it helps people as much as it helps me.