gjsify / ts-for-gir

TypeScript type definition generator for GObject introspection interfaces
https://gjsify.org/pages/projects
Apache License 2.0
233 stars 20 forks source link

Create an import for the latest version in `*-ambient.d.ts` #174

Open vixalien opened 2 months ago

vixalien commented 2 months ago

For example Gtk generates a gtk-4.0-ambient.d.ts

declare module 'gi://Gtk?version=4.0' {
    const Gtk40: typeof import('./gtk-4.0.js').default;
    export default Gtk40;
}

Because this is the latest version, it would also be amazing to create the file with an additional import that doesn't include the ?version=4.0

declare module 'gi://Gtk?version=4.0' {
    const Gtk40: typeof import('./gtk-4.0.js').default;
    export default Gtk40;
}

declare module 'gi://Gtk' {
    const Gtk40: typeof import('./gtk-4.0.js').default;
    export default Gtk40;
}

But on second thought, having this feature only for modules that don't have conflicting versions would be the better idea.

JumpLink commented 2 months ago

@vixalien which version do you use? In @girs/gtk-4.0 v4.14.3-4.0.0-beta.5 gi://Gtk is already exported without the version affix because it's the latest version. This is also the case for the other GObject libraries. Can you give it a try?

vixalien commented 2 months ago

Oh nice. I just used the latest stable version with npx ts-for-gir.

I'll retry and update you!

JumpLink commented 1 month ago

@vixalien With the latest version, all Ambient Modules are now generated without a version string. With the CLI argument --onlyVersionPrefix this can be deactivated, then only Ambient Modules with version strings are generated. Please give feedback if this works for you :)