-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] PoC Typescript support #11276
base: master
Are you sure you want to change the base?
[WIP] PoC Typescript support #11276
Conversation
Yeah.. all the dependencies are a slight problem. This would also mean that this TS would have to integrate with CJS otherwise everyone would have to install Node But having to bootstrap the other Gir's isn't ideal - it's like what Gtk-Rs is doing and for one repo that's a bit crazy |
GNOME's sound recorder just ported to TS. They are using Yarn and this tool: https://gitlab.gnome.org/ewlsh/gi.ts It will probably be way cleaner if we go with the gi.ts route. There is still a types folder but IMO assuming that it is okay to have TS and it's bindings in the main cinnamon repository (meaning it is a requirement to be built and maintained by distributors) then I think this is feasible Next move forward personally would be trying to work with gi.ts Edit: the current files changed looks close enough to what a result of gi.ts would look like but if TS and bindings are being bundled into Cinnamon, may I suggest writing some example applets/desklets/extensions to show that this works? |
I'm in the process of trying out gi.ts but currently I have trouble building the declarations for Cinnamon with it. For examples of spices, here they are: They are either using the declarations in the applets repo (it was requested to be bundled for review) or the npm package. Both of them are basically the files included in this WIP. All of them are using webpack for convenience (and to get around annoying import issues with Edit: I managed to build it with a minor modification to gi.ts (had to comment out |
I finally had time to check https://gitlab.gnome.org/ewlsh/gi.ts against the current weather applet codebase. After the minor fix (mentioned in the previous comment) to It doesn't inject them under imports, a declaration file is needed somewhere: import * as Atk from "atk";
import * as St from "st";
import * as Gio from "gio";
import * as GLib from "glib";
import * as Soup from "soup";
import * as Clutter from "clutter";
import * as Gtk from "gtk";
import * as GObject from "gobject";
declare global {
const _: (text: string) => string;
const logError: (...args: any[]) => void;
namespace imports {
namespace gi {
export {
St,
Clutter,
Atk,
Gio,
GLib,
Soup,
Gtk,
GObject
}
}
} The location of the file above should depend on where we store/generate the declaration files or where injection actually happens. It also can be broken up to more files - Typescript automatically merges So far the only problem I found is that I have a hard time override/extend the Currently the only way I can see for extending is directly modify Gr3q/cinnamon-spices-applets#12 - changes for weather applet built against |
Currently with shitty structure for internal use (within Cinnamon repo) only. c lib declarations are copy-pasted from GIR2TS for now
TODO:
.gir
files doesn't respect theshadowed-by
property, needs to be fixed..gir
files doesn't handle array types well in some cases, needs to be fixed..gir
files doesn't handleuser_data andtypes for callbacks (generics), needs to be fixedjs
andd.ts
files#11272