jsii-diff 1.113.0 → 1.115.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.
package/bin/jsii-diff.js CHANGED
@@ -11,6 +11,7 @@ const diagnostics_1 = require("../lib/diagnostics");
11
11
  const util_1 = require("../lib/util");
12
12
  const version_1 = require("../lib/version");
13
13
  const LOG = log4js.getLogger('jsii-diff');
14
+ const ASSEMBLY_SUPPORTED_FEATURES = ['intersection-types'];
14
15
  async function main() {
15
16
  const argv = await yargs
16
17
  .env('JSII_DIFF')
@@ -177,9 +178,15 @@ async function loadFromFilesystem(name, options) {
177
178
  const stat = await fs.stat(name);
178
179
  const ts = new reflect.TypeSystem();
179
180
  if (stat.isDirectory()) {
180
- return ts.loadModule(name, options);
181
+ return ts.loadModule(name, {
182
+ ...options,
183
+ supportedFeatures: ASSEMBLY_SUPPORTED_FEATURES,
184
+ });
181
185
  }
182
- return ts.loadFile(name, options);
186
+ return ts.loadFile(name, {
187
+ ...options,
188
+ supportedFeatures: ASSEMBLY_SUPPORTED_FEATURES,
189
+ });
183
190
  }
184
191
  main()
185
192
  .then((n) => {
@@ -56,6 +56,22 @@ function isSuperType(a, b, updatedSystem) {
56
56
  }
57
57
  return failure(`none of ${b.toString()} are assignable to ${a.toString()}`, ...(0, util_1.flatMap)(analyses, (x) => (x.success ? [] : x.reasons)));
58
58
  }
59
+ // intersection A ⊒ B <=> all of the elements of A ⊒ B
60
+ if (a.intersectionOfTypes !== undefined) {
61
+ const analyses = a.intersectionOfTypes.map((aaa) => isSuperType(aaa, b, updatedSystem));
62
+ if (analyses.every((x) => x.success)) {
63
+ return { success: true };
64
+ }
65
+ return failure(`${b.toString()} is not assignable to all of ${a.toString()}`, ...(0, util_1.flatMap)(analyses, (x) => (x.success ? [] : x.reasons)));
66
+ }
67
+ // A ⊒ intersection B <=> A ⊒ any of the elements of B
68
+ if (b.intersectionOfTypes !== undefined) {
69
+ const analyses = b.intersectionOfTypes.map((bbb) => isSuperType(a, bbb, updatedSystem));
70
+ if (analyses.some((x) => x.success)) {
71
+ return { success: true };
72
+ }
73
+ return failure(`some of ${b.toString()} are not assignable to ${a.toString()}`, ...(0, util_1.flatMap)(analyses, (x) => (x.success ? [] : x.reasons)));
74
+ }
59
75
  // We have two named types, recursion might happen so protect against it.
60
76
  try {
61
77
  // For named types, we'll always do a nominal typing relationship.
package/lib/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** The qualified version number for this JSII compiler. */
2
- export declare const VERSION = "1.113.0 (build fc68b25)";
2
+ export declare const VERSION = "1.115.0 (build 9c5134e)";
3
3
  //# sourceMappingURL=version.d.ts.map
package/lib/version.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- // Generated at 2025-07-31T12:48:06Z by generate.sh
2
+ // Generated at 2025-09-29T13:26:02Z by generate.sh
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.VERSION = void 0;
5
5
  /** The qualified version number for this JSII compiler. */
6
- exports.VERSION = '1.113.0 (build fc68b25)';
6
+ exports.VERSION = '1.115.0 (build 9c5134e)';
7
7
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsii-diff",
3
- "version": "1.113.0",
3
+ "version": "1.115.0",
4
4
  "description": "Assembly comparison for jsii",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -33,18 +33,19 @@
33
33
  "package": "package-js"
34
34
  },
35
35
  "dependencies": {
36
- "@jsii/check-node": "1.113.0",
37
- "@jsii/spec": "^1.113.0",
36
+ "@jsii/check-node": "1.115.0",
37
+ "@jsii/spec": "1.115.0",
38
38
  "fs-extra": "^10.1.0",
39
- "jsii-reflect": "^1.113.0",
39
+ "jsii-reflect": "^1.115.0",
40
40
  "log4js": "^6.9.1",
41
- "yargs": "^16.2.0"
41
+ "yargs": "^17.7.2"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/fs-extra": "^9.0.13",
45
45
  "@types/tar-fs": "^2.0.4",
46
+ "@types/yargs": "^17.0.33",
46
47
  "jest-expect-message": "^1.1.3",
47
- "jsii": "^5.8.0",
48
- "jsii-build-tools": "^1.113.0"
48
+ "jsii": "^5.9.6",
49
+ "jsii-build-tools": "^1.115.0"
49
50
  }
50
51
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type-intersections.test.d.ts.map
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const util_1 = require("./util");
4
+ jest.setTimeout(50000);
5
+ const PREAMBLE = `
6
+ export interface IFoo {
7
+ readonly foo: string;
8
+ }
9
+
10
+ export interface IBar {
11
+ readonly bar: string;
12
+ }
13
+
14
+ export interface IBaz {
15
+ readonly baz: string;
16
+ }
17
+
18
+ export interface ICombined extends IFoo, IBar { }
19
+ `;
20
+ describe.each(['argument', 'prop'])('%s position', (where) => {
21
+ function sources(old, noo) {
22
+ return [old, noo].map((type) => {
23
+ switch (where) {
24
+ case 'argument':
25
+ return `
26
+ ${PREAMBLE}
27
+ export class Api {
28
+ public static fooAndBar(x: ${type}) {
29
+ void(x);
30
+ return '';
31
+ }
32
+ }`;
33
+ case 'prop':
34
+ return `
35
+ ${PREAMBLE}
36
+ export interface Props {
37
+ readonly input: ${type};
38
+ }
39
+ export class Api {
40
+ public static fooAndBar(props: Props) {
41
+ Array.isArray(props);
42
+ return '';
43
+ }
44
+ }`;
45
+ }
46
+ });
47
+ }
48
+ // ----------------------------------------------------------------------
49
+ test('types can remain unchanged', () => (0, util_1.expectNoError)(...sources('IFoo & IBar', 'IFoo & IBar')));
50
+ // ----------------------------------------------------------------------
51
+ test('can turn interface into intersection', () => (0, util_1.expectNoError)(...sources('ICombined', 'IFoo & IBar')));
52
+ // ----------------------------------------------------------------------
53
+ test('can not turn interface into intersection that requires a non-extended type', () => (0, util_1.expectError)(/testpkg.ICombined does not extend testpkg.IBaz/, ...sources('ICombined', 'IFoo & IBaz')));
54
+ // ----------------------------------------------------------------------
55
+ test('can turn part of union into intersection', () => (0, util_1.expectNoError)(...sources('string | ICombined', 'string | (IFoo & IBar)')));
56
+ // ----------------------------------------------------------------------
57
+ test('can require fewer intersection elements', () => (0, util_1.expectNoError)(...sources('IFoo & IBar & IBaz', 'IFoo & IBar')));
58
+ // ----------------------------------------------------------------------
59
+ test('can not add intersection elements', () => (0, util_1.expectError)(/some of testpkg.IBar & testpkg.IFoo are not assignable to testpkg.IBaz/, ...sources('IFoo & IBar', 'IFoo & IBar & IBaz')));
60
+ });
61
+ // ----------------------------------------------------------------------
62
+ test('allow requiring a new interface in intersection if interface is extended at the same time', () => (0, util_1.expectNoError)(`
63
+ ${PREAMBLE}
64
+ export interface IChangeable extends IFoo {}
65
+
66
+ export class Api {
67
+ public static fooAndBar(x: IChangeable) {
68
+ void(x);
69
+ return '';
70
+ }
71
+ }`, `
72
+ ${PREAMBLE}
73
+ export interface IChangeable extends IFoo, IBar {}
74
+
75
+ export class Api {
76
+ public static fooAndBar(x: IFoo & IBar) {
77
+ void(x);
78
+ return '';
79
+ }
80
+ }`));
81
+ //# sourceMappingURL=type-intersections.test.js.map
package/test/util.js CHANGED
@@ -11,7 +11,7 @@ function expectNoError(original, updated) {
11
11
  for (const msg of mms.messages()) {
12
12
  console.error(`- ${msg}`);
13
13
  }
14
- expect(mms.count).toBe(0);
14
+ expect(Array.from(mms.messages())).toEqual([]);
15
15
  }
16
16
  function expectError(error, original, updated) {
17
17
  if (error == null) {