@ts-for-gir/generator-typescript 4.0.0-beta.43 → 4.0.0-beta.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-for-gir/generator-typescript",
3
- "version": "4.0.0-beta.43",
3
+ "version": "4.0.0-beta.44",
4
4
  "description": "TypeScript type definition generator for ts-for-gir",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -31,17 +31,17 @@
31
31
  "generator"
32
32
  ],
33
33
  "devDependencies": {
34
- "@ts-for-gir/tsconfig": "^4.0.0-beta.43",
34
+ "@ts-for-gir/tsconfig": "^4.0.0-beta.44",
35
35
  "@types/ejs": "^3.1.5",
36
36
  "@types/node": "^24.12.0",
37
37
  "@types/xml2js": "^0.4.14",
38
38
  "typescript": "^6.0.2"
39
39
  },
40
40
  "dependencies": {
41
- "@gi.ts/parser": "^4.0.0-beta.43",
42
- "@ts-for-gir/generator-base": "^4.0.0-beta.43",
43
- "@ts-for-gir/lib": "^4.0.0-beta.43",
44
- "@ts-for-gir/templates": "^4.0.0-beta.43",
41
+ "@gi.ts/parser": "^4.0.0-beta.44",
42
+ "@ts-for-gir/generator-base": "^4.0.0-beta.44",
43
+ "@ts-for-gir/lib": "^4.0.0-beta.44",
44
+ "@ts-for-gir/templates": "^4.0.0-beta.44",
45
45
  "ejs": "^5.0.1",
46
46
  "xml2js": "^0.6.2"
47
47
  }
@@ -55,6 +55,7 @@ import {
55
55
  type TsDocTag,
56
56
  TypeConflict,
57
57
  type TypeExpression,
58
+ TypeIdentifier,
58
59
  transformGirDocTagTextWithContext,
59
60
  transformGirDocText,
60
61
  } from "@ts-for-gir/lib";
@@ -517,6 +518,13 @@ export class ModuleGenerator extends FormatGenerator<string[]> {
517
518
  const Type = type.resolve(this.namespace, this.options).rootPrint(this.namespace, this.options) || "any";
518
519
 
519
520
  if (construct) {
521
+ // If the property type is GType, use GTypeInput to also accept class constructors
522
+ // with $gtype (e.g., passing a class to Gio.ListStore's item_type property)
523
+ const unwrapped = type.deepUnwrap();
524
+ if (unwrapped instanceof TypeIdentifier && unwrapped.is("GObject", "GType")) {
525
+ const gtypeNamespace = this.namespace.namespace === "GObject" ? "" : "GObject.";
526
+ return [`${name}: ${gtypeNamespace}GTypeInput;`];
527
+ }
520
528
  return [`${name}: ${Type};`];
521
529
  }
522
530