-
Notifications
You must be signed in to change notification settings - Fork 40
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
Types for typescript #280
Comments
From what I've understood we'll need to add a "types" field in package.json to point to our typings. The typings generated by ts-for-gjs are slightly wrong, and will need some work. |
List of things that need to be adjusted/verified:
More details here. I'd be fine with including types directly with this module, we could use ts-for-gjs as a dev dependency to pregenerate typings. |
This is just running ts-for-gjs without any cleanup for the newest versions of the libraries including Gtk4: https://github.com/TheBlueOompaLoompa/node-gtk |
Looks like a good start, here are the list of things I'd aim to get fixed before merging:
That should get us mostly correct types. Do you have an interest in adjusting the types? If not, I'll surely get around to this but not sure when. |
I will try to work on types because right now I'm working on a project with Gtk4. I think I will start at the newest versions and work backwards starting with Gtk4 and then Gtk3. No Gtk2 because anyone still working on a project with it should have upgraded a while ago. Maybe I will have time for the other libraries but Gtk is first. |
The decision to add types is a delicate one IMHO... I'm not sure it's a good idea since:
Typings are awesome, but when they have inconsistencies (some libraries silently do not get typechecked, some properties get silently ignored at runtime, etc.) they can be very confusing. An alternative is to instruct users to place a "prepare": "ts-for-gir <libraries they want to use, or *> -o lib/codegen", Then ignore import { Button } from './lib/codegen/Gtk-1.0' This solves all problems above. The drawback is the extra setup work. There are plenty of other cases where you need to generate code (Protobuf, gRPC, OpenAPI, etc.) so I don't think we'd be asking for anything nonstandard here. |
It's fine to make it an additional install step, we just need to make sure to make it very clear and easy, the most annoying thing with typings is installing them :] We could add |
agreed that it should be as easy & straightforward as possible. adding it as a dependency doesn't feel right bc it's only a devDependency, but it's justified I think. maybe we could do it as a post-install step? |
Yes, post-install step is good. I guess we can explore all that and find a good compromise once someone gets started on this. It's on my task list but so are so many other things :| |
Is there any news on how soon the types can be added? |
No sorry :/ You can get what is available up and running by following the instructions on https://github.com/sammydre/ts-for-gjs, but it will require manually setting them up on your part. |
@romgrk @gavr123456789 @TheBlueOompaLoompa @mildsunrise I released ts-for-gir v3.0.0 🚀 now. I encourage you to explore ts-for-gir / the NPM packages and provide your valuable feedback 🤗️ |
Neat packaging 👍 |
Adding types would allow faster development because of intellisense and the typescript compiler would be able to catch errors in the users syntax.
This is the tool that could be used for generating the typings: https://github.com/sammydre/ts-for-gjs
I don't understand how typings are added to node modules like this but I will look into how it has been done for other libraries.
See discussion here: #266 (comment)
The text was updated successfully, but these errors were encountered: