Skip to content
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

Error could not generify Gtk-4.0 when trying to generate types for Soup-3.0 #248

Open
1 of 3 tasks
TheDogHusky opened this issue Mar 23, 2025 · 3 comments · May be fixed by #249
Open
1 of 3 tasks

Error could not generify Gtk-4.0 when trying to generate types for Soup-3.0 #248

TheDogHusky opened this issue Mar 23, 2025 · 3 comments · May be fixed by #249
Labels

Comments

@TheDogHusky
Copy link

Description

I use Soup-3.0 in my projects, tried installing the types through the cli (ts-for-gir generate Soup-3.0)n, and an error occurs.

Current vs Expected Behavior

Current:

[adam@TOUR-ADAM NyarchUpdater]$ ts-for-gir generate Soup-3.0
Adding generics...
ts-for-gir generate [modules..]

Generates Typescript type definition .d.ts files from GIR for GJS

Options :
      --version                 Affiche le numéro de version           [booléen]
      --help                    Affiche l'aide                         [booléen]
      --modules                 GIR modules to load, e.g. 'Gio-2.0'. Accepts mul
                                tiple modules         [tableau] [défaut : ["*"]]
  -g, --girDirectories          GIR directories
  [tableau] [défaut : ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/sha
  re/*/gir-1.0","/usr/share/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/
      lib64/mutter-*","/usr/lib/mutter-*","/usr/lib/x86_64-linux-gnu/mutter-*"]]
      --root                    Root directory of your project
            [chaîne de caractères] [défaut : "/home/adam/Projets/NyarchUpdater"]
  -o, --outdir                  Directory to output to
                                    [chaîne de caractères] [défaut : "./@types"]
  -i, --ignore                  Modules that should be ignored
                                                         [tableau] [défaut : []]
  -v, --verbose                 Switch on/off the verbose mode
                                         [chaîne de caractères] [défaut : false]
      --ignoreVersionConflicts  Skip prompts for library version selection when
                                multiple versions are detected
                                         [chaîne de caractères] [défaut : false]
  -p, --print                   Print the output to console and create no files
                                         [chaîne de caractères] [défaut : false]
      --configName              Specify a custom name for the configuration file
                            [chaîne de caractères] [défaut : ".ts-for-girrc.js"]
  -d, --noNamespace             Do not export all symbols for each module as a n
                                amespace [chaîne de caractères] [défaut : false]
  -n, --noComments              Do not generate documentation comments
                                         [chaîne de caractères] [défaut : false]
      --promisify               Generate promisified functions for async/finish
                                calls     [chaîne de caractères] [défaut : true]
      --npmScope                Scope of the generated NPM packages
                                       [chaîne de caractères] [défaut : "@girs"]
      --workspace               Uses the workspace protocol for the generated pa
                                ckages which can be used with package managers l
                                ike Yarn and PNPM
                                         [chaîne de caractères] [défaut : false]
      --onlyVersionPrefix       Only use the version prefix for the ambient modu
                                le exports. This is useful if, for whatever reas
                                on, you want to use different library versions o
                                f the same library in your project.
                                         [chaîne de caractères] [défaut : false]
      --noPrettyPrint           Do not prettify the generated types
                                         [chaîne de caractères] [défaut : false]
      --noAdvancedVariants      Disable GLib.Variant class with string parsing
                                          [chaîne de caractères] [défaut : true]
      --package                 Generate the typescript types with package.json
                                support  [chaîne de caractères] [défaut : false]

Exemples :
  ts-for-gir generate                       Run 'ts-for-gir generate' in your gj
                                            s project to generate typings for yo
                                            ur project, pass the gir modules you
                                             need for your project
  ts-for-gir generate Gtk*                  You can also use wild cards
  ts-for-gir generate '*'                   If you want to parse all of your loc
                                            ally installed gir modules run
  ts-for-gir generate --configName='.ts-fo  Use a special config file
  r-gir.gtk4.rc.js
  ts-for-gir generate --ignore=Gtk-4.0 xra  Generate .d.ts. files but not for Gt
  ndr-1.3                                   k-4.0 and xrandr-1.3

Error: Could not generify Gtk 4.0
    at file:///home/adam/.nvm/versions/node/v20.18.3/lib/node_modules/@ts-for-gir/cli/node_modules/@ts-for-gir/lib/lib/generics/generify.js:17:19
    at generify (file:///home/adam/.nvm/versions/node/v20.18.3/lib/node_modules/@ts-for-gir/cli/node_modules/@ts-for-gir/lib/lib/generics/generify.js:25:5)
    at DependencyManager.transform (file:///home/adam/.nvm/versions/node/v20.18.3/lib/node_modules/@ts-for-gir/cli/node_modules/@ts-for-gir/lib/lib/gir/registry.js:105:9)
    at GenerationHandler.start (file:///home/adam/.nvm/versions/node/v20.18.3/lib/node_modules/@ts-for-gir/cli/lib/generation-handler.js:35:18)
    at async Object.handler (file:///home/adam/.nvm/versions/node/v20.18.3/lib/node_modules/@ts-for-gir/cli/lib/commands/generate.js:32:5)

Expected:
Should make me the types defs.

Example

References

Running ts-for-gir generate Gtk-4.0 or Adw-1 works fine.

Additional Context

  • This affects other GJS types/classes
  • This is a regression from a previous version
  • This blocks other functionality
@JumpLink
Copy link
Collaborator

I can confirm the behaviour and it is definitely a bug. I'll take a look at it. As a workaround, you can pass Gtk-4.0 with it, then it works:

@ts-for-gir/cli generate Gtk-4.0 Soup-3.0

Regarding the package name, I agree that ts-for-gir would be more handy. Unfortunately, someone has published our repo under this name on NPM without asking and all attempts to contact them have unfortunately failed: https://www.npmjs.com/package/ts-for-gir

@JumpLink JumpLink linked a pull request Mar 24, 2025 that will close this issue
@TheDogHusky
Copy link
Author

Hey!
Thanks for the reply, i'll try out.
As for ts-for-gir package, i wasn't talking about the fact typing the whole cli package name was an issue, just that using npx to execute it is way longer.

@JumpLink
Copy link
Collaborator

I wasn't talking about the fact typing the whole cli package name was an issue, just that using npx to execute it is way longer.

Oh, sorry, yes, I do that myself too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants