jsii-pacmak 1.117.0 → 1.118.0

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.
@@ -51,6 +51,7 @@ export declare class ClassMethod extends GoMethod {
51
51
  constructor(parent: GoClass, method: Method);
52
52
  emit(context: EmitContext): void;
53
53
  emitDecl({ code, documenter }: EmitContext): void;
54
+ private get returnTypeForDocs();
54
55
  get instanceArg(): string;
55
56
  get static(): boolean;
56
57
  get specialDependencies(): SpecialDependencies;
@@ -13,6 +13,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
13
13
  var _GoClass_parameterValidators, _GoClassConstructor_validator;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.StaticMethod = exports.ClassMethod = exports.GoClassConstructor = exports.GoClass = void 0;
16
+ const jsii_reflect_1 = require("jsii-reflect");
16
17
  const naming_util_1 = require("../../../naming-util");
17
18
  const comparators = require("../comparators");
18
19
  const runtime_1 = require("../runtime");
@@ -306,8 +307,20 @@ class ClassMethod extends type_member_1.GoMethod {
306
307
  emitDecl({ code, documenter }) {
307
308
  const returnTypeString = this.reference?.void ? '' : ` ${this.returnType}`;
308
309
  documenter.emit(this.method.docs, this.apiLocation);
310
+ // Document the actual return type
311
+ if (this.returnTypeForDocs !== this.returnType) {
312
+ documenter.emit(new jsii_reflect_1.Docs(this.method.system, this.method, {
313
+ summary: `Returns \`${this.returnTypeForDocs}\`, use interface conversion if needed`,
314
+ }), this.apiLocation);
315
+ }
309
316
  code.line(`${this.name}(${this.paramString()})${returnTypeString}`);
310
317
  }
318
+ get returnTypeForDocs() {
319
+ if (jsii_reflect_1.Method.isMethod(this.method) && this.method.returns.type) {
320
+ return new go_type_reference_1.GoTypeRef(this.parent.pkg.root, this.method.returns.type).scopedReference(this.parent.pkg);
321
+ }
322
+ return this.method.toString();
323
+ }
311
324
  get instanceArg() {
312
325
  return this.parent.name.substring(0, 1).toLowerCase();
313
326
  }
@@ -115,10 +115,8 @@ class GoTypeRef {
115
115
  }
116
116
  break;
117
117
  case 'intersection':
118
- if (!this.options.opaqueUnionTypes) {
119
- for (const t of this.typeMap.value) {
120
- ret.push(...t.dependencies);
121
- }
118
+ for (const t of this.typeMap.value) {
119
+ ret.push(...t.dependencies);
122
120
  }
123
121
  break;
124
122
  case 'void':
@@ -19,12 +19,14 @@ export declare class GoProperty implements GoTypeMember {
19
19
  readonly setterName: string;
20
20
  readonly immutable: boolean;
21
21
  protected readonly apiLocation: ApiLocation;
22
+ private _propertyForSignature?;
22
23
  constructor(parent: GoType, property: Property);
23
24
  get validator(): ParameterValidator | undefined;
24
25
  get reference(): GoTypeRef;
25
26
  get specialDependencies(): SpecialDependencies;
26
27
  get static(): boolean;
27
28
  get returnType(): string;
29
+ private get returnTypeForDocs();
28
30
  get instanceArg(): string;
29
31
  get override(): string;
30
32
  emitStructMember({ code, documenter }: EmitContext): void;
@@ -32,15 +34,33 @@ export declare class GoProperty implements GoTypeMember {
32
34
  emitSetterDecl({ code, documenter }: EmitContext): void;
33
35
  emitGetterProxy(context: EmitContext): void;
34
36
  emitSetterProxy(context: EmitContext): void;
37
+ /**
38
+ * Returns the property we're overriding
39
+ *
40
+ * This is necessary because jsii allows classes to make the type of
41
+ * properties in subclasses more specific (this is known as "covariant return
42
+ * types"), but Go doesn't support this feature.
43
+ *
44
+ * If we render the signature of the property itself, and it has changed its
45
+ * return type, Go will see that as two conflicting definitions of the same
46
+ * accessor method.
47
+ *
48
+ * So instead, we will always render the type signature of the topmost method.
49
+ * That is either the same as the current method (in which case it doesn't make
50
+ * a difference), or it is a different signature, but then that's the one
51
+ * we need to render to prevent the method collission.
52
+ */
53
+ get propertyForSignature(): Property;
35
54
  }
36
55
  export declare abstract class GoMethod implements GoTypeMember {
37
56
  #private;
38
57
  readonly parent: GoClass | GoInterface;
39
58
  readonly method: Callable;
40
59
  readonly name: string;
41
- readonly parameters: GoParameter[];
42
60
  protected readonly apiLocation: ApiLocation;
61
+ private _methodForSignature?;
43
62
  constructor(parent: GoClass | GoInterface, method: Callable);
63
+ get parameters(): GoParameter[];
44
64
  get validator(): ParameterValidator | undefined;
45
65
  abstract emit(context: EmitContext): void;
46
66
  abstract get specialDependencies(): SpecialDependencies;
@@ -51,6 +71,23 @@ export declare abstract class GoMethod implements GoTypeMember {
51
71
  get override(): string;
52
72
  get static(): boolean;
53
73
  paramString(): string;
74
+ /**
75
+ * Returns the first method we're overriding
76
+ *
77
+ * This is necessary because jsii allows classes to make the return type of
78
+ * methods in subclasses more specific (this is known as "covariant return
79
+ * types"), but Go doesn't support this feature.
80
+ *
81
+ * If we render the signature of the method itself, and it has changed its
82
+ * return type, Go will see that as two conflicting definitions of the same
83
+ * method.
84
+ *
85
+ * So instead, we will always render the type signature of the topmost method.
86
+ * That is either the same as the current method (in which case it doesn't make
87
+ * a difference), or it is a different signature, but then that's the one
88
+ * we need to render to prevent the method collision.
89
+ */
90
+ get methodForSignature(): Callable;
54
91
  }
55
92
  export declare class GoParameter {
56
93
  readonly name: string;
@@ -49,7 +49,7 @@ class GoProperty {
49
49
  return __classPrivateFieldGet(this, _GoProperty_validator, "f");
50
50
  }
51
51
  get reference() {
52
- return new index_1.GoTypeRef(this.parent.pkg.root, this.property.type);
52
+ return new index_1.GoTypeRef(this.parent.pkg.root, this.propertyForSignature.type);
53
53
  }
54
54
  get specialDependencies() {
55
55
  return {
@@ -65,7 +65,10 @@ class GoProperty {
65
65
  }
66
66
  get returnType() {
67
67
  return (this.reference?.scopedReference(this.parent.pkg) ??
68
- this.property.type.toString());
68
+ this.propertyForSignature.type.toString());
69
+ }
70
+ get returnTypeForDocs() {
71
+ return (new index_1.GoTypeRef(this.parent.pkg.root, this.property.type).scopedReference(this.parent.pkg) ?? this.property.type.toString());
69
72
  }
70
73
  get instanceArg() {
71
74
  return this.parent.proxyName.substring(0, 1).toLowerCase();
@@ -78,13 +81,21 @@ class GoProperty {
78
81
  const memberType = this.reference?.type?.name === this.parent.name
79
82
  ? `*${this.returnType}`
80
83
  : this.returnType;
81
- const requiredOrOptional = this.property.optional ? 'optional' : 'required';
84
+ const requiredOrOptional = this.propertyForSignature.optional
85
+ ? 'optional'
86
+ : 'required';
82
87
  // Adds json and yaml tags for easy deserialization
83
88
  code.line(`${this.name} ${memberType} \`field:"${requiredOrOptional}" json:"${this.property.name}" yaml:"${this.property.name}"\``);
84
89
  // TODO add newline if not the last member
85
90
  }
86
91
  emitGetterDecl({ code, documenter }) {
87
92
  documenter.emit(this.property.docs, this.apiLocation);
93
+ // Document the actual return type
94
+ if (this.returnTypeForDocs !== this.returnType) {
95
+ documenter.emit(new jsii_reflect_1.Docs(this.property.system, this.property, {
96
+ summary: `Returns \`${this.returnTypeForDocs}\`, use interface conversion if needed`,
97
+ }), this.apiLocation);
98
+ }
88
99
  code.line(`${this.name}() ${this.returnType}`);
89
100
  }
90
101
  emitSetterDecl({ code, documenter }) {
@@ -129,6 +140,37 @@ class GoProperty {
129
140
  code.line();
130
141
  }
131
142
  }
143
+ /**
144
+ * Returns the property we're overriding
145
+ *
146
+ * This is necessary because jsii allows classes to make the type of
147
+ * properties in subclasses more specific (this is known as "covariant return
148
+ * types"), but Go doesn't support this feature.
149
+ *
150
+ * If we render the signature of the property itself, and it has changed its
151
+ * return type, Go will see that as two conflicting definitions of the same
152
+ * accessor method.
153
+ *
154
+ * So instead, we will always render the type signature of the topmost method.
155
+ * That is either the same as the current method (in which case it doesn't make
156
+ * a difference), or it is a different signature, but then that's the one
157
+ * we need to render to prevent the method collission.
158
+ */
159
+ get propertyForSignature() {
160
+ // Cache for speed
161
+ if (this._propertyForSignature) {
162
+ return this._propertyForSignature;
163
+ }
164
+ let ret = this.property;
165
+ while (true) {
166
+ const next = ret.overriddenProperty;
167
+ if (!next) {
168
+ this._propertyForSignature = ret;
169
+ return ret;
170
+ }
171
+ ret = next;
172
+ }
173
+ }
132
174
  }
133
175
  exports.GoProperty = GoProperty;
134
176
  _GoProperty_validator = new WeakMap();
@@ -138,12 +180,14 @@ class GoMethod {
138
180
  this.method = method;
139
181
  _GoMethod_validator.set(this, null);
140
182
  this.name = (0, naming_util_1.jsiiToPascalCase)(method.name);
141
- this.parameters = this.method.parameters.map((param) => new GoParameter(parent, param));
142
183
  this.apiLocation =
143
184
  method.kind === jsii_reflect_1.MemberKind.Initializer
144
185
  ? { api: 'initializer', fqn: parent.fqn }
145
186
  : { api: 'member', fqn: parent.fqn, memberName: method.name };
146
187
  }
188
+ get parameters() {
189
+ return this.methodForSignature.parameters.map((param) => new GoParameter(this.parent, param));
190
+ }
147
191
  get validator() {
148
192
  if (__classPrivateFieldGet(this, _GoMethod_validator, "f") === null) {
149
193
  __classPrivateFieldSet(this, _GoMethod_validator, runtime_type_checking_1.ParameterValidator.forMethod(this), "f");
@@ -151,8 +195,9 @@ class GoMethod {
151
195
  return __classPrivateFieldGet(this, _GoMethod_validator, "f");
152
196
  }
153
197
  get reference() {
154
- if (jsii_reflect_1.Method.isMethod(this.method) && this.method.returns.type) {
155
- return new index_1.GoTypeRef(this.parent.pkg.root, this.method.returns.type);
198
+ const sig = this.methodForSignature;
199
+ if (jsii_reflect_1.Method.isMethod(sig) && sig.returns.type) {
200
+ return new index_1.GoTypeRef(this.parent.pkg.root, sig.returns.type);
156
201
  }
157
202
  return undefined;
158
203
  }
@@ -166,7 +211,8 @@ class GoMethod {
166
211
  return false;
167
212
  }
168
213
  get returnType() {
169
- return (this.reference?.scopedReference(this.parent.pkg) ?? this.method.toString());
214
+ return (this.reference?.scopedReference(this.parent.pkg) ??
215
+ this.methodForSignature.toString());
170
216
  }
171
217
  get instanceArg() {
172
218
  return this.parent.name.substring(0, 1).toLowerCase();
@@ -182,6 +228,42 @@ class GoMethod {
182
228
  ? ''
183
229
  : this.parameters.map((p) => p.toString()).join(', ');
184
230
  }
231
+ /**
232
+ * Returns the first method we're overriding
233
+ *
234
+ * This is necessary because jsii allows classes to make the return type of
235
+ * methods in subclasses more specific (this is known as "covariant return
236
+ * types"), but Go doesn't support this feature.
237
+ *
238
+ * If we render the signature of the method itself, and it has changed its
239
+ * return type, Go will see that as two conflicting definitions of the same
240
+ * method.
241
+ *
242
+ * So instead, we will always render the type signature of the topmost method.
243
+ * That is either the same as the current method (in which case it doesn't make
244
+ * a difference), or it is a different signature, but then that's the one
245
+ * we need to render to prevent the method collision.
246
+ */
247
+ get methodForSignature() {
248
+ // Cache for speed
249
+ if (this._methodForSignature) {
250
+ return this._methodForSignature;
251
+ }
252
+ // Not sure why `this.method :: Callable` and not `this.method :: Method`, but
253
+ // let's be safe.
254
+ if (!(this.method instanceof jsii_reflect_1.Method)) {
255
+ return this.method;
256
+ }
257
+ let ret = this.method;
258
+ while (true) {
259
+ const next = ret.overriddenMethod;
260
+ if (!next) {
261
+ this._methodForSignature = ret;
262
+ return ret;
263
+ }
264
+ ret = next;
265
+ }
266
+ }
185
267
  }
186
268
  exports.GoMethod = GoMethod;
187
269
  _GoMethod_validator = new WeakMap();
package/lib/targets/go.js CHANGED
@@ -45,8 +45,11 @@ class Golang extends target_1.Target {
45
45
  // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
46
46
  return Promise.reject(e);
47
47
  }
48
- if (process.env.JSII_BUILD_GO) {
49
- // This step is taken to ensure that the generated code is compilable
48
+ // This step is taken to ensure that the generated code is compilable
49
+ // Do it by default, because we didn't use to and that was masking a code generation
50
+ // problem.
51
+ const doBuild = !['false', '0', 'no'].includes(process.env.JSII_BUILD_GO ?? '1');
52
+ if (doBuild) {
50
53
  await go('build', ['-modfile', localGoMod.path, './...'], {
51
54
  cwd: pkgDir,
52
55
  });
package/lib/version.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** The short version number for this jsii-pacmak release (e.g: `X.Y.Z`) */
2
2
  export declare const VERSION: string;
3
3
  /** The qualified version number for this jsii-pacmak release (e.g: `X.Y.Z (build #######)`) */
4
- export declare const VERSION_DESC = "1.117.0 (build b8499c7)";
4
+ export declare const VERSION_DESC = "1.118.0 (build 02eec31)";
5
5
  //# sourceMappingURL=version.d.ts.map
package/lib/version.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
- // Generated at 2025-10-22T16:32:40Z by generate.sh
2
+ // Generated at 2025-10-29T09:48:29Z by generate.sh
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.VERSION_DESC = exports.VERSION = void 0;
5
5
  /** The short version number for this jsii-pacmak release (e.g: `X.Y.Z`) */
6
6
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
7
- exports.VERSION = '1.117.0';
7
+ exports.VERSION = '1.118.0';
8
8
  /** The qualified version number for this jsii-pacmak release (e.g: `X.Y.Z (build #######)`) */
9
- exports.VERSION_DESC = '1.117.0 (build b8499c7)';
9
+ exports.VERSION_DESC = '1.118.0 (build 02eec31)';
10
10
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsii-pacmak",
3
- "version": "1.117.0",
3
+ "version": "1.118.0",
4
4
  "description": "A code generation framework for jsii backend languages",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,24 +37,24 @@
37
37
  "package": "package-js"
38
38
  },
39
39
  "dependencies": {
40
- "@jsii/check-node": "1.117.0",
41
- "@jsii/spec": "1.117.0",
40
+ "@jsii/check-node": "1.118.0",
41
+ "@jsii/spec": "1.118.0",
42
42
  "clone": "^2.1.2",
43
- "codemaker": "^1.117.0",
43
+ "codemaker": "^1.118.0",
44
44
  "commonmark": "^0.31.2",
45
45
  "escape-string-regexp": "^4.0.0",
46
46
  "fs-extra": "^10.1.0",
47
- "jsii-reflect": "^1.117.0",
47
+ "jsii-reflect": "^1.118.0",
48
48
  "semver": "^7.7.2",
49
49
  "spdx-license-list": "^6.10.0",
50
50
  "xmlbuilder": "^15.1.1",
51
51
  "yargs": "^17.7.2"
52
52
  },
53
53
  "devDependencies": {
54
- "@jsii/dotnet-runtime": "^1.117.0",
55
- "@jsii/go-runtime": "^1.117.0",
56
- "@jsii/java-runtime": "^1.117.0",
57
- "@scope/jsii-calc-lib": "^1.117.0",
54
+ "@jsii/dotnet-runtime": "^1.118.0",
55
+ "@jsii/go-runtime": "^1.118.0",
56
+ "@jsii/java-runtime": "^1.118.0",
57
+ "@scope/jsii-calc-lib": "^1.118.0",
58
58
  "@types/clone": "^2.1.4",
59
59
  "@types/commonmark": "^0.27.10",
60
60
  "@types/diff": "^5.2.3",
@@ -63,7 +63,7 @@
63
63
  "@types/yargs": "^17.0.33",
64
64
  "diff": "^5.2.0",
65
65
  "jsii": "^5.9.10",
66
- "jsii-build-tools": "^1.117.0",
66
+ "jsii-build-tools": "^1.118.0",
67
67
  "jsii-calc": "^3.20.120",
68
68
  "jsii-rosetta": "~5.9.10",
69
69
  "pyright": "^1.1.403"