-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Draft: Switch to ts-for-gir
for TypeScript definitions
#979
base: main
Are you sure you want to change the base?
Conversation
will require you to do ``` git submodule sync git submodule update --init --recursive --remote ```
It would be nice to get help with the " Add the support for hover providers" item on the tasklist. I've been talking with @andyholmes , and we think the correct way would be to generate the types would be to generate them within Workbench itself. However, this will require we switch back to GNOME Master (see #980) |
Also related: workbenchdev/demos#201 |
A significant milestone! Now Workbench can build the However, the JavaScript files outputted are a bit different. For example, here is the TypeScript (source) import Adw from "gi://Adw";
import Gio from "gi://Gio";
import Gtk from "gi://Gtk?version=4.0";
Gio._promisify(Adw.AlertDialog.prototype, "choose", "choose_finish");
const box = workbench.builder.get_object("subtitle") as Gtk.Box;
const button = new Gtk.Button({
label: "Press me",
margin_top: 6,
css_classes: ["suggested-action"],
});
button.connect("clicked", () => {
greet().catch(console.error);
});
box.append(button);
console.log("Welcome to Workbench!");
async function greet() {
const dialog = new Adw.AlertDialog({
body: "Hello World!",
});
dialog.add_response("ok", "OK");
const response = await dialog.choose(workbench.window, null);
console.log(response);
} JavaScript (compiled) import Adw from "gi://Adw";
import Gio from "gi://Gio";
import Gtk from "gi://Gtk?version=4.0";
Gio._promisify(Adw.AlertDialog.prototype, "choose", "choose_finish");
const box = workbench.builder.get_object("subtitle");
const button = new Gtk.Button({
label: "Press me",
margin_top: 6,
css_classes: ["suggested-action"],
});
button.connect("clicked", () => {
greet().catch(console.error);
});
box.append(button);
console.log("Welcome to Workbench!");
async function greet() {
const dialog = new Adw.AlertDialog({
body: "Hello World!",
});
dialog.add_response("ok", "OK");
const response = await dialog.choose(workbench.window, null);
console.log(response);
} I talked this in the past with @sonnyp and we thought it was fine at the moment, but today I'm not so sure if it's adequate. We talked about using alternative compilers for this task (maybe It may also be beneficial to activate the |
Note: to test this, you will also need to have workbenchdev/demos#201 |
Because the submodule has changed. You will probably need to run:
Types Repo
I'm currently using my own types repository at https://github.com/vixalien/gi-typescript-definitions. These types are generated manually (but I wish they were generated each week). The reason I'm using my own repo is because the (de facto) upstream https://gitlab.gnome.org/BrainBlasted/gi-typescript-definitions has not been updated yet.
Workbench types
I vaguely remember ts-for-gir being able to generate types for Workbench. But I'm not too sure of how it's gonna work. Will we generate the types manually and put them in the repo, and recompile the types everytime a GIR is generated? I'm not too sure and I need help in these regards.
GJS types
The types in
ambient.d.ts
has been removed in favor ofgjs.d.ts
in the types generated byts-for-gir
.Hover provider
In my experience, you can't really hover on a type to get definitions, and I think this needs implementing in Workbench. I'd be happy to take pointers on how to implement this feature to get type information on hover.
Remaining issues/TODO
dom.d.ts
types don't seem to be included. I don't know why, and I hope we can find a way to get output from the language server about thisambient.d.ts
ambient.d.ts
toworkbench.d.ts