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

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.42",
3
+ "version": "4.0.0-beta.43",
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.42",
34
+ "@ts-for-gir/tsconfig": "^4.0.0-beta.43",
35
35
  "@types/ejs": "^3.1.5",
36
36
  "@types/node": "^24.12.0",
37
37
  "@types/xml2js": "^0.4.14",
38
- "typescript": "^5.9.3"
38
+ "typescript": "^6.0.2"
39
39
  },
40
40
  "dependencies": {
41
- "@gi.ts/parser": "^4.0.0-beta.42",
42
- "@ts-for-gir/generator-base": "^4.0.0-beta.42",
43
- "@ts-for-gir/lib": "^4.0.0-beta.42",
44
- "@ts-for-gir/templates": "^4.0.0-beta.42",
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",
45
45
  "ejs": "^5.0.1",
46
46
  "xml2js": "^0.6.2"
47
47
  }
@@ -107,8 +107,6 @@ export class SignalGenerator {
107
107
  const allSignals = girClass.getAllSignals();
108
108
 
109
109
  allSignals.forEach((signalInfo) => {
110
- const signalKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(signalInfo.name) ? signalInfo.name : `"${signalInfo.name}"`;
111
-
112
110
  let cbType: string;
113
111
 
114
112
  if (signalInfo.isNotifySignal) {
@@ -132,6 +130,14 @@ export class SignalGenerator {
132
130
  cbType = `(${paramTypes.join(", ")}) => ${returnTypeStr}`;
133
131
  }
134
132
 
133
+ // Template literal catch-all signals use index signature syntax
134
+ if (signalInfo.isTemplateLiteral) {
135
+ def.push(`${indent} [key: \`${signalInfo.name}\`]: ${cbType};`);
136
+ return;
137
+ }
138
+
139
+ const signalKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(signalInfo.name) ? signalInfo.name : `"${signalInfo.name}"`;
140
+
135
141
  // Add signal doc comment with @signal tag and signal-specific modifier tags
136
142
  if (!signalInfo.isNotifySignal && signalInfo.signal) {
137
143
  const signalTags = [
@@ -402,14 +402,16 @@ export class ModuleGenerator extends FormatGenerator<string[]> {
402
402
 
403
403
  clazz.superType = GLibError.getType();
404
404
 
405
- // Manually construct a GLib.Error constructor.
405
+ // GJS GError constructor expects one object: { message: string, code: number }
406
+ // The domain is automatically derived from the error enum type.
407
+ // See: gjs/gi/gerror.cpp ErrorInstance::constructor_impl
406
408
  clazz.mainConstructor = new IntrospectedConstructor({
407
409
  name: "new",
408
410
  parent: clazz,
409
411
  parameters: [
410
412
  new IntrospectedFunctionParameter({
411
413
  name: "options",
412
- type: NativeType.of("{ message: string, code: number}"),
414
+ type: NativeType.of("{ message: string, code: number }"),
413
415
  direction: GirDirection.In,
414
416
  }),
415
417
  ],
@@ -1272,6 +1274,7 @@ export class ModuleGenerator extends FormatGenerator<string[]> {
1272
1274
  else if (girClass.mainConstructor instanceof IntrospectedConstructor)
1273
1275
  def.push(...this.generateConstructor(girClass.mainConstructor));
1274
1276
  else if (
1277
+ (girClass.namespace.namespace === "GObject" && girClass.name === "Object") ||
1275
1278
  girClass.someParent((p: IntrospectedBaseClass) => p.namespace.namespace === "GObject" && p.name === "Object")
1276
1279
  )
1277
1280
  def.push(`\nconstructor(properties?: Partial<${girClass.name}.ConstructorProps>, ...args: any[]);\n`);