Monday, February 27, 2017

Sorting out Gjs with Typescript

I get why Gnome wants to use javascript. I love the language. The thing is, I don't love Gnome's implementation.

The syntax is getting out of date, and my experience with other engines doesn't translate well to the Gjs environment. Combine this with a lack of documentation. If Gnome wants to attract javascript developers, this isn't the way to do it. Its not too bad when you are coding a one page demo widget, but try coding an ambitious desktop application. Without relevant api information, I'm coding blindfolded.

One solution would be to use Typescript. All I need to do is translate the *.gir metadata to *.d.ts format, so I've created a tool

https://www.npmjs.com/package/gir2dts

All I have to do is install with npm, and reference the contained *.d.ts files.

There are a couple of samples in the example folder at https://github.com/darkoverlordofdata/gir2dts

This tool was designed to facillitate the development of another application, so it's a great example of a Gjs/Typescript application: https://github.com/darkoverlordofdata/bosco-player

7 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Really good work. I agree wholeheartedly with your assertion that "If Gnome wants to attract javascript developers, this isn't the way to do it."

    And Typescript does look very appealing. Visual Studio Code, with your GTK typescript files, and therefore "intellisense" for the GTK libraries is really quite nice.

    One of the awkward things about GJS is how it handles modules. Have you looked into whether it is sane to try and support NodeJS (CommonJS I suppose) modules, and Typescript, with GJS?

    ReplyDelete
  3. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from TypeScript Training in Chennai . or learn thru Javascript Online Training from India. Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Training in Chennai

    ReplyDelete
  4. Now you can win free stuff online, free giveaways, enter every day to win latest iphones, smartphones, macbooks, laptops, accessories, technology and much more.

    Participate, Win & Keep A Free Apple iPhone XS

    ReplyDelete
  5. Sickbits is a library of unlimited hacks for android, ios smartphones. Get unlimited amount of hacks and modes for mac & pc. https://sickbits.net/

    ReplyDelete