definitelytyped-firefox-webext-browser icon indicating copy to clipboard operation
definitelytyped-firefox-webext-browser copied to clipboard

Generating types for Thunderbird

Open Juraj-Masiar opened this issue 4 years ago • 1 comments

Could this be used to generate types also for Thunderbird? I mean for the new WebExtension API in the new Thunderbird 78: https://webextension-api.thunderbird.net/en/78/index.html (it's mostly the same API but with some special namespaces for handling email related things)

Juraj-Masiar avatar Jan 20 '21 10:01 Juraj-Masiar

Depends on if mozilla is using the same Chrome-ish format for their schema files. Not something I personally have an interest in tho, but I'll keep the issue open in case anyone is wondering the same.

jsmnbom avatar Jan 28 '21 20:01 jsmnbom

The library @types/thunderbird-webext-browser is now in DefinitelyTyped and npm. I forked this project and adjusted it to the Thunderbird WebExtension API.

@jsmnbom most of my edits have to do with the specifics of Thunderbird's schemas, but perhaps some may be useful for your project (or perhaps not). Specifically:

  • Dealing with optional parameters in functions. That often means adding 'overloads', and I changed the algorithm for the creation of the overloads so it creates the smallest number of them. This also avoids some linting errors of type unified-signatures. My code is in the second half of the convertFunction method of the Converter class.
  • Hard-wrapping long lines in comments. This is mostly aesthetic, but it avoids max-line-length linting errors. It's in the same source file: I first import a function from the prettier library to do the wrapping, then use it in two places where comments are formatted. By the way, I also use it for the final output of the program.
  • Newlines in comments: to make sure \n\n in a description is translated into a double newline in the comment (which means a new paragraph in the mouse-over description in an IDE), I added a line to the descToMarkdown function.
  • I have nested the namespaces: instead of declare namespace browser.accounts {...} and declare namespace browser.i18n {...} and so on, I have declare namespace browser {namespace accounts {...} namespace i18n {...} ...}. The reasons have to do with, among other things, the way Visual Studio Code creates the help descriptions that show on mouse-over of a namespace. See here for my findings on this. It is done with a few small changes in four places.

Other changes, like a more complicated download procedure, additional export keywords, and code to create a special version that works better in the WebStorm coding environment, are probably not very relevant for you.

JimDanner avatar Mar 17 '23 12:03 JimDanner

Thank you Jim! I've just tested in my Darko and ScrollAnywhere addons for Thunderbird and it works great! Great job!

Juraj-Masiar avatar Mar 17 '23 12:03 Juraj-Masiar

Gonna close this since @JimDanner 's fork fulfills this purpose ^^ https://github.com/JimDanner/definitelytyped-thunderbird-webext-browser

Thanks <3

jsmnbom avatar Jul 30 '23 17:07 jsmnbom