Wartybix / GNOME-Auto-Accent-Colour

GNOME extension to automatically change the desktop accent colour based on the user's wallpaper.
https://extensions.gnome.org/extension/7502/auto-accent-colour/
GNU General Public License v3.0
9 stars 1 forks source link

Use TypeScript (help suggestion) #1

Open ExposedCat opened 3 days ago

ExposedCat commented 3 days ago

Are you considering using TypeScript for development? It's the same, but with static types.

Pros:

Cons:

If you are good with it, I can help by creating initial PR.

Wartybix commented 3 days ago

Yes, I did look at TypeScript. I followed the GJS tutorial before I made this extension, but I remember having some errors when compiling TypeScript files into JavaScript -- something about lots of duplicate identifiers in files of the node_modules/@girs/ directory. Either I did something wrong, or there was something weird with those NPM packages that day, but I couldn't figure out the problem. Plus, most of the other extensions I was looking at as references were written directly in JavaScript, so I just wrote mine in JS too.

I do understand the benefits of TypeScript though, like strong typing, and all the extra IDE goodies that come with it. I'm happy to revisit using TypeScript for this project if you'd like. I went through the tutorial I mentioned earlier again after reading your issue, and I don't have the same problem when compiling as I did before.

Would you like to create the pull request? If so, I can merge it if there aren't any problems. Otherwise, I can give it a go instead. The only thing I can think of being a hassle is the Makefile's handling of the PO files. Right now, I use the gnome-extensions pack command (the whole command can be seen in pack.sh in the repository) to publish my source code to the extensions store for review. This automatically converts every file in the po/ directory to something along the lines of locale/<language code>/LC_MESSAGES/auto-accent-colour@Wartybix.mo. I wonder if it would be better to replicate this behaviour directly in the Makefile, or make the pack phony target populate the dist/ directory with the JS files, schemas, icons, PO files, etc., as usual, and then run pack.sh on said dist/ directory to create a ZIP file ready for publishing with all the PO files converted to MO files and so on. The latter way sounds easier, but I don't have much TypeScript experience beyond one tutorial, so maybe you have a better idea?

ExposedCat commented 2 days ago

@Wartybix I didn't use po/locales in extensions yet, so not sure. I don't use Makefile, just build and zip it, you can check this. Either way I can make PR to the dev branch for example. I also suggest using Biome instead of eslint, it replaces both eslint and prettier in a single package and IMO works more stable

Wartybix commented 2 days ago

Ah okay, thank you for the example you provided. That looks a lot more intuitive and easy to understand than the Makefile actually. I think where you have your zip command, I would replace with gnome-extensions pack ..., as the gnome-extensions command creates a similar ZIP file, with the PO files correctly compiled to MO files. I have created a new dev branch, so you can submit a pull request there if you like.

Your comment inspired me to actually pay attention to my ESLint warnings, so I've been spending the last few hours down a rabbit hole fixing them all, changing my ESLint GitHub Actions workflow, as well as adding some changes to my preferences window. I don't think I want to switch to Biome, as what I have already works for me. GNOME Builder has support for ESLint out of the box, and I can copy the config file for it directly from the GJS guide. I'm not that fussed by the faster execution time and whatnot that Biome has. ESLint gets the job done well enough I think.