jsii 5.9.5-dev.4 → 5.9.5-dev.5

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.
@@ -15,7 +15,6 @@ export declare class Assembler implements Emitter {
15
15
  private readonly mainFile;
16
16
  private readonly tscRootDir?;
17
17
  private readonly compressAssembly?;
18
- private readonly usedFeatures;
19
18
  private readonly _typeChecker;
20
19
  private _diagnostics;
21
20
  private _deferred;
@@ -57,7 +56,7 @@ export declare class Assembler implements Emitter {
57
56
  *
58
57
  * @param fqn FQN of the current type (the type that has a dependency on baseTypes)
59
58
  * @param baseTypes Array of type references to be looked up
60
- * @param referencingNode Node to report a diagnostic on if we fail to look up a type
59
+ * @param referencingNode Node to report a diagnostic on if we fail to look up a t ype
61
60
  * @param cb Callback to be invoked with the Types corresponding to the TypeReferences in baseTypes
62
61
  */
63
62
  private _deferUntilTypesAvailable;
@@ -165,26 +164,11 @@ export declare class Assembler implements Emitter {
165
164
  private _toParameter;
166
165
  private _typeReference;
167
166
  private _optionalValue;
168
- /**
169
- * Validate the restrictions on an intersection type reference
170
- *
171
- * - Type only consists of (behavioral) interface types
172
- * - For all types referenced in the intersection, the definitions of all shared
173
- * members must match exactly.
174
- */
175
- private validateIntersectionType;
176
- private comparePropForIntersection;
177
- private compareMethodForIntersection;
178
167
  private callDeferredsInOrder;
179
168
  /**
180
169
  * Return the set of all (inherited) properties of an interface
181
170
  */
182
171
  private allProperties;
183
- /**
184
- * Return the set of all (inherited) methods of an interface
185
- */
186
- private allMethods;
187
- private allInterfacesRecursively;
188
172
  private _verifyConsecutiveOptionals;
189
173
  /**
190
174
  * Updates the runtime type info with the fully-qualified name for the current class definition.
@@ -197,13 +181,6 @@ export declare class Assembler implements Emitter {
197
181
  */
198
182
  private mySubmodules;
199
183
  private findPackageInfo;
200
- /**
201
- * Validate types against input/output positions in functions and APIs
202
- *
203
- * Currently used to validate that intersection types are only used in input position,
204
- * not output position
205
- */
206
- private validateTypesAgainstPositions;
207
184
  }
208
185
  export interface AssemblerOptions {
209
186
  /**
package/lib/assembler.js CHANGED
@@ -19,13 +19,10 @@ const jsii_diagnostic_1 = require("./jsii-diagnostic");
19
19
  const literate = require("./literate");
20
20
  const bindings = require("./node-bindings");
21
21
  const reserved_words_1 = require("./reserved-words");
22
- const sets_1 = require("./sets");
23
22
  const deprecated_remover_1 = require("./transforms/deprecated-remover");
24
23
  const deprecation_warnings_1 = require("./transforms/deprecation-warnings");
25
24
  const runtime_info_1 = require("./transforms/runtime-info");
26
25
  const utils_1 = require("./transforms/utils");
27
- const type_reference_1 = require("./type-reference");
28
- const type_visitor_1 = require("./type-visitor");
29
26
  const utils_2 = require("./utils");
30
27
  const validator_1 = require("./validator");
31
28
  const version_1 = require("./version");
@@ -47,7 +44,6 @@ class Assembler {
47
44
  this.system = system;
48
45
  this.program = program;
49
46
  this.stdlib = stdlib;
50
- this.usedFeatures = new Set();
51
47
  this._diagnostics = new Array();
52
48
  this._deferred = new Array();
53
49
  this._types = new Map();
@@ -139,7 +135,6 @@ class Assembler {
139
135
  }
140
136
  }
141
137
  this.callDeferredsInOrder();
142
- this.validateTypesAgainstPositions();
143
138
  // Skip emitting if any diagnostic message is an error
144
139
  if (this._diagnostics.find((diag) => diag.category === ts.DiagnosticCategory.Error) != null) {
145
140
  LOG.debug('Skipping emit due to errors.');
@@ -183,7 +178,6 @@ class Assembler {
183
178
  jsiiVersion,
184
179
  bin: this.projectInfo.bin,
185
180
  fingerprint: '<TBD>',
186
- usedFeatures: this.usedFeatures.size > 0 ? Array.from(this.usedFeatures) : undefined,
187
181
  };
188
182
  if (this.deprecatedRemover) {
189
183
  this._diagnostics.push(...this.deprecatedRemover.removeFrom(assembly));
@@ -257,7 +251,7 @@ class Assembler {
257
251
  *
258
252
  * @param fqn FQN of the current type (the type that has a dependency on baseTypes)
259
253
  * @param baseTypes Array of type references to be looked up
260
- * @param referencingNode Node to report a diagnostic on if we fail to look up a type
254
+ * @param referencingNode Node to report a diagnostic on if we fail to look up a t ype
261
255
  * @param cb Callback to be invoked with the Types corresponding to the TypeReferences in baseTypes
262
256
  */
263
257
  _deferUntilTypesAvailable(fqn, baseTypes, referencingNode, cb) {
@@ -266,19 +260,9 @@ class Assembler {
266
260
  cb();
267
261
  return;
268
262
  }
269
- const baseFqns = baseTypes.flatMap((bt) => {
270
- if (typeof bt === 'string') {
271
- return [bt];
272
- }
273
- if (spec.isNamedTypeReference(bt)) {
274
- return [bt.fqn];
275
- }
276
- return [];
277
- });
263
+ const baseFqns = baseTypes.map((bt) => (typeof bt === 'string' ? bt : bt.fqn));
278
264
  this._defer(fqn, baseFqns, () => {
279
- const resolved = baseFqns
280
- .map((x) => this._dereference(x, referencingNode, 'used-in-syntax'))
281
- .filter((x) => x !== undefined);
265
+ const resolved = baseFqns.map((x) => this._dereference(x, referencingNode)).filter((x) => x !== undefined);
282
266
  if (resolved.length > 0) {
283
267
  cb(...resolved);
284
268
  }
@@ -306,7 +290,7 @@ class Assembler {
306
290
  *
307
291
  * @returns the de-referenced type, if it was found, otherwise ``undefined``.
308
292
  */
309
- _dereference(ref, referencingNode, usedInSyntax) {
293
+ _dereference(ref, referencingNode) {
310
294
  if (typeof ref !== 'string') {
311
295
  ref = ref.fqn;
312
296
  }
@@ -327,7 +311,7 @@ class Assembler {
327
311
  }
328
312
  }
329
313
  }
330
- if (!type && usedInSyntax === 'used-in-syntax') {
314
+ if (!type) {
331
315
  this._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_9002_UNRESOLVEABLE_TYPE.create(referencingNode, // Cheating here for now, until the referencingNode can be made required
332
316
  ref));
333
317
  }
@@ -406,7 +390,7 @@ class Assembler {
406
390
  assembly: dep,
407
391
  });
408
392
  const fqn = (dep && symbolId ? symbolIdIndex(dep)[symbolId] : undefined) ?? fallbackFqn;
409
- if (!fqn || !this._dereference({ fqn }, sym.valueDeclaration, 'used-in-syntax')) {
393
+ if (!fqn || !this._dereference({ fqn }, sym.valueDeclaration)) {
410
394
  if (!hasError) {
411
395
  this._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_3002_USE_OF_UNEXPORTED_FOREIGN_TYPE.create(typeAnnotationNode, fqn ?? tsName, typeUse, pkg).addRelatedInformationIf(typeDeclaration, 'The referenced type is declared here'));
412
396
  hasError = true;
@@ -1019,12 +1003,9 @@ class Assembler {
1019
1003
  if (signature) {
1020
1004
  for (const param of signature.getParameters()) {
1021
1005
  jsiiType.initializer.parameters = jsiiType.initializer.parameters ?? [];
1022
- const jsiiParam = // eslint-disable-next-line no-await-in-loop
1023
- this._toParameter(param, ctx.replaceStability(jsiiType.docs?.stability));
1024
- if (containsIntersection(jsiiParam.type)) {
1025
- this._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_1010_INTERSECTION_NOT_IN_CTOR.create(param.declarations?.[0]));
1026
- }
1027
- jsiiType.initializer.parameters.push(jsiiParam);
1006
+ jsiiType.initializer.parameters.push(
1007
+ // eslint-disable-next-line no-await-in-loop
1008
+ this._toParameter(param, ctx.replaceStability(jsiiType.docs?.stability)));
1028
1009
  jsiiType.initializer.variadic = jsiiType.initializer?.parameters?.some((p) => !!p.variadic) || undefined;
1029
1010
  jsiiType.initializer.protected =
1030
1011
  (ts.getCombinedModifierFlags(ctorDeclaration) & ts.ModifierFlags.Protected) !== 0 || undefined;
@@ -1086,7 +1067,7 @@ class Assembler {
1086
1067
  .filter((x) => !x.static)
1087
1068
  .map((x) => x.name));
1088
1069
  // Intersect
1089
- for (const member of sets_1.Sets.intersect(statics, nonStatics)) {
1070
+ for (const member of intersect(statics, nonStatics)) {
1090
1071
  this._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_5013_STATIC_INSTANCE_CONFLICT.create(decl, member, klass));
1091
1072
  }
1092
1073
  // Check against base classes. They will not contain duplicate member names so we can load
@@ -1452,7 +1433,7 @@ class Assembler {
1452
1433
  // Liftable datatype, make sure no parameter names match any of the properties in the datatype
1453
1434
  const propNames = this.allProperties(lastParamType);
1454
1435
  const paramNames = new Set(parameters.slice(0, parameters.length - 1).map((x) => x.name));
1455
- const sharedNames = sets_1.Sets.intersection(propNames, paramNames);
1436
+ const sharedNames = intersection(propNames, paramNames);
1456
1437
  for (const badName of sharedNames) {
1457
1438
  this._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_5017_POSITIONAL_KEYWORD_CONFLICT.create(declaration, badName));
1458
1439
  }
@@ -1587,18 +1568,7 @@ class Assembler {
1587
1568
  return { type: primitiveType };
1588
1569
  }
1589
1570
  if (type.isUnion() && !_isEnumLike(type)) {
1590
- return _setType.call(this, 'union');
1591
- }
1592
- if (type.isIntersection()) {
1593
- this.usedFeatures.add('intersection-types');
1594
- const ret = _setType.call(this, 'intersection');
1595
- const intersectionType = ret.type;
1596
- this.validateIntersectionType(intersectionType, declaration);
1597
- return ret;
1598
- }
1599
- if ((type.getFlags() & ts.TypeFlags.Never) !== 0) {
1600
- this._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_1007_NEVER_TYPE.create(declaration));
1601
- return { type: spec.CANONICAL_ANY };
1571
+ return _unionType.call(this);
1602
1572
  }
1603
1573
  if (!type.symbol) {
1604
1574
  this._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_1001_TYPE_HAS_NO_SYMBOL.create(declaration));
@@ -1704,7 +1674,7 @@ class Assembler {
1704
1674
  // Not a primitive type!
1705
1675
  return undefined;
1706
1676
  }
1707
- function _setType(field) {
1677
+ function _unionType() {
1708
1678
  const types = new Array();
1709
1679
  let optional;
1710
1680
  for (const subType of type.types) {
@@ -1719,112 +1689,16 @@ class Assembler {
1719
1689
  }
1720
1690
  types.push(resolvedType);
1721
1691
  }
1722
- const returnedType = {
1723
- [field]: { types },
1724
- };
1725
- return types.length === 1 ? { optional, type: types[0] } : { optional, type: returnedType };
1692
+ return types.length === 1 ? { optional, type: types[0] } : { optional, type: { union: { types } } };
1726
1693
  }
1727
1694
  }
1728
- /**
1729
- * Validate the restrictions on an intersection type reference
1730
- *
1731
- * - Type only consists of (behavioral) interface types
1732
- * - For all types referenced in the intersection, the definitions of all shared
1733
- * members must match exactly.
1734
- */
1735
- validateIntersectionType(intersectionType, declaration) {
1736
- // Validate that this intersection type only consists of interface types
1737
- this._deferUntilTypesAvailable('', intersectionType.intersection.types, declaration, (...elementTypes) => {
1738
- const requestedFqns = new Set(intersectionType.intersection.types.map(type_reference_1.typeReferenceToString));
1739
- const resolvedFqns = new Set(elementTypes.map((t) => t.fqn));
1740
- const unresolved = sets_1.Sets.diff(requestedFqns, resolvedFqns);
1741
- if (unresolved.size > 0) {
1742
- this._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_1008_ONLY_INTERFACE_INTERSECTION.create(declaration, Array.from(unresolved).join(', ')));
1743
- }
1744
- const nonBehavioral = elementTypes.filter((t) => !(0, type_visitor_1.isBehavioralInterfaceType)(t));
1745
- if (nonBehavioral.length > 0) {
1746
- this._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_1008_ONLY_INTERFACE_INTERSECTION.create(declaration, nonBehavioral.map((t) => t.fqn).join(', ')));
1747
- }
1748
- // Check that shared members are the same
1749
- const interfaces = elementTypes.filter(type_visitor_1.isBehavioralInterfaceType);
1750
- const allProps = sets_1.Sets.union(...interfaces.map((int) => this.allProperties(int)));
1751
- const allMethods = sets_1.Sets.union(...interfaces.map((int) => this.allMethods(int)));
1752
- for (let i = 1; i < interfaces.length; i++) {
1753
- let int0 = interfaces[0];
1754
- let int1 = interfaces[i];
1755
- for (const prop of allProps) {
1756
- const p1 = int0.properties?.find((p) => p.name === prop);
1757
- const p2 = int1.properties?.find((p) => p.name === prop);
1758
- const diff = this.comparePropForIntersection(p1, p2);
1759
- if (diff) {
1760
- this._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_1011_INTERSECTION_MEMBER_DIFFERENT.create(declaration, prop, int0.name, diff[0], int1.name, diff[1]));
1761
- }
1762
- }
1763
- for (const meth of allMethods) {
1764
- const m1 = int0.methods?.find((p) => p.name === meth);
1765
- const m2 = int1.methods?.find((p) => p.name === meth);
1766
- const diff = this.compareMethodForIntersection(m1, m2);
1767
- if (diff) {
1768
- this._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_1011_INTERSECTION_MEMBER_DIFFERENT.create(declaration, meth, int0.name, diff[0], int1.name, diff[1]));
1769
- }
1770
- }
1771
- }
1772
- });
1773
- }
1774
- comparePropForIntersection(a, b) {
1775
- if (!a || !b) {
1776
- return undefined;
1777
- }
1778
- if (!(0, type_reference_1.typeReferenceEqual)(a.type, b.type)) {
1779
- return [(0, type_reference_1.typeReferenceToString)(a.type), (0, type_reference_1.typeReferenceToString)(b.type)];
1780
- }
1781
- return (cmpDesc(a.static, b.static, (s) => (s ? 'static' : 'instance member')) ??
1782
- cmpDesc(a.optional, b.optional, (o) => (o ? 'optional' : 'required')) ??
1783
- cmpDesc(a.abstract, b.abstract, (s) => (s ? 'abstract' : 'concrete')));
1784
- }
1785
- compareMethodForIntersection(a, b) {
1786
- if (!a || !b) {
1787
- return undefined;
1788
- }
1789
- if (a.returns && b.returns) {
1790
- if (!(0, type_reference_1.typeReferenceEqual)(a.returns.type, b.returns.type)) {
1791
- return [(0, type_reference_1.typeReferenceToString)(a.returns.type), (0, type_reference_1.typeReferenceToString)(b.returns.type)];
1792
- }
1793
- const x = cmpDesc(a.returns.optional, b.returns.optional, (o) => o ? 'return type optional' : 'return type required');
1794
- if (x) {
1795
- return x;
1796
- }
1797
- }
1798
- const paramsA = a.parameters ?? [];
1799
- const paramsB = b.parameters ?? [];
1800
- if (paramsA.length !== paramsB.length) {
1801
- return [`${paramsA.length} parameters`, `${paramsB.length} parameters`];
1802
- }
1803
- for (let i = 0; i < paramsA.length; i++) {
1804
- const p1 = paramsA[i];
1805
- const p2 = paramsB[i];
1806
- if (!(0, type_reference_1.typeReferenceEqual)(p1.type, p2.type)) {
1807
- return [(0, type_reference_1.typeReferenceToString)(p1.type), (0, type_reference_1.typeReferenceToString)(p2.type)];
1808
- }
1809
- const x = cmpDesc(p1.optional, p2.optional, (o) => (o ? `parameter ${i + 1} optional` : `parameter ${i + 1} required`)) ??
1810
- cmpDesc(p1.variadic, p2.variadic, (v) => v ? `parameter ${i + 1} variadic` : `parameter ${i + 1} not variadic`);
1811
- if (x) {
1812
- return x;
1813
- }
1814
- }
1815
- return (cmpDesc(a.abstract, b.abstract, (s) => (s ? 'abstract' : 'concrete')) ??
1816
- cmpDesc(a.async, b.async, (s) => (s ? 'async' : 'async')) ??
1817
- cmpDesc(a.protected, b.protected, (p) => (p ? 'protected' : 'public')) ??
1818
- cmpDesc(a.variadic, b.variadic, (v) => (v ? 'variadic' : 'non-variadic')) ??
1819
- cmpDesc(a.static, b.static, (s) => (s ? 'static' : 'instance member')));
1820
- }
1821
1695
  callDeferredsInOrder() {
1822
1696
  // Do a topological call order of all deferreds.
1823
1697
  while (this._deferred.length > 0) {
1824
1698
  // All fqns in dependency lists that don't have any pending
1825
1699
  // deferreds themselves can be executed now, so are removed from
1826
1700
  // dependency lists.
1827
- const pendingFqns = new Set(this._deferred.map((x) => x.fqn).filter((x) => x));
1701
+ const pendingFqns = new Set(this._deferred.map((x) => x.fqn));
1828
1702
  for (const deferred of this._deferred) {
1829
1703
  restrictDependenciesTo(deferred, pendingFqns);
1830
1704
  }
@@ -1853,33 +1727,20 @@ class Assembler {
1853
1727
  * Return the set of all (inherited) properties of an interface
1854
1728
  */
1855
1729
  allProperties(root) {
1856
- return this.allInterfacesRecursively(root, (int) => {
1857
- return (int.properties ?? []).map((p) => p.name);
1858
- });
1859
- }
1860
- /**
1861
- * Return the set of all (inherited) methods of an interface
1862
- */
1863
- allMethods(root) {
1864
- return this.allInterfacesRecursively(root, (int) => {
1865
- return (int.methods ?? []).map((p) => p.name);
1866
- });
1867
- }
1868
- allInterfacesRecursively(root, cb) {
1869
1730
  const ret = new Set();
1870
1731
  recurse.call(this, root);
1871
1732
  return ret;
1872
1733
  function recurse(int) {
1873
- for (const x of cb(int)) {
1874
- ret.add(x);
1734
+ for (const property of int.properties ?? []) {
1735
+ ret.add(property.name);
1875
1736
  }
1876
1737
  for (const baseRef of int.interfaces ?? []) {
1877
- const base = this._dereference(baseRef, undefined, 'used-in-syntax');
1738
+ const base = this._dereference(baseRef, undefined);
1878
1739
  if (!base) {
1879
- throw new Error('Impossible to have unresolvable base in allInterfacesRecursively()');
1740
+ throw new Error('Impossible to have unresolvable base in allProperties()');
1880
1741
  }
1881
1742
  if (!spec.isInterfaceType(base)) {
1882
- throw new Error('Impossible to have non-interface base in allInterfacesRecursively()');
1743
+ throw new Error('Impossible to have non-interface base in allProperties()');
1883
1744
  }
1884
1745
  recurse.call(this, base);
1885
1746
  }
@@ -1935,89 +1796,6 @@ class Assembler {
1935
1796
  return this.findPackageInfo(parent);
1936
1797
  }
1937
1798
  }
1938
- /**
1939
- * Validate types against input/output positions in functions and APIs
1940
- *
1941
- * Currently used to validate that intersection types are only used in input position,
1942
- * not output position
1943
- */
1944
- validateTypesAgainstPositions() {
1945
- const self = this;
1946
- const validatedFqns = {
1947
- in: new Set(),
1948
- out: new Set(),
1949
- };
1950
- for (const type of this._types.values()) {
1951
- if (spec.isClassType(type)) {
1952
- for (const ctorParam of type.initializer?.parameters ?? []) {
1953
- validateRefFor.call(this, 'in', ctorParam.type, `a constructor parameter of ${type.name}`);
1954
- }
1955
- }
1956
- if (spec.isClassType(type) || (0, type_visitor_1.isBehavioralInterfaceType)(type)) {
1957
- for (const property of type.properties ?? []) {
1958
- validateRefFor.call(this, 'out', property.type, `type of property ${type.name}.${property.name}`);
1959
- }
1960
- for (const method of type.methods ?? []) {
1961
- for (const param of method.parameters ?? []) {
1962
- validateRefFor.call(this, 'in', param.type, `a parameter of method ${type.name}.${method.name}()`);
1963
- }
1964
- if (method.returns) {
1965
- validateRefFor.call(this, 'out', method.returns.type, `return type of method ${type.name}.${method.name}()`);
1966
- }
1967
- }
1968
- }
1969
- }
1970
- function validateRefFor(dir, typeRef, reason) {
1971
- (0, type_visitor_1.visitTypeReference)(typeRef, {
1972
- named: (ref) => {
1973
- // Named types we'll only validate once for every direction
1974
- if (validatedFqns[dir].has(ref.fqn)) {
1975
- return;
1976
- }
1977
- validatedFqns[dir].add(ref.fqn);
1978
- const type = self._dereference(ref, undefined, 'just-validating');
1979
- if (!type) {
1980
- // Maybe this is an unexported type.
1981
- return;
1982
- }
1983
- validateTypeFor(dir, type, reason);
1984
- },
1985
- primitive: () => { },
1986
- collection: (ref) => {
1987
- validateRefFor(dir, ref.collection.elementtype, reason);
1988
- },
1989
- union: (ref) => {
1990
- for (const t of ref.union.types) {
1991
- validateRefFor(dir, t, reason);
1992
- }
1993
- },
1994
- intersection: (ref) => {
1995
- if (dir === 'out') {
1996
- self._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_1009_INTERSECTION_ONLY_INPUT.createDetached(reason));
1997
- }
1998
- for (const t of ref.intersection.types) {
1999
- validateRefFor(dir, t, reason);
2000
- }
2001
- },
2002
- });
2003
- }
2004
- function validateTypeFor(dir, type, reason) {
2005
- (0, type_visitor_1.visitType)(type, {
2006
- dataType: (t) => {
2007
- // We only need to validate data types, because classes and interfaces
2008
- // are done as part of the main loop.
2009
- //
2010
- // Recurse.
2011
- for (const prop of t.properties ?? []) {
2012
- validateRefFor(dir, prop.type, `type of property ${t.name}.${prop.name}, ${reason}`);
2013
- }
2014
- },
2015
- classType: () => { },
2016
- interfaceType: () => { },
2017
- enumType: () => { },
2018
- });
2019
- }
2020
- }
2021
1799
  }
2022
1800
  exports.Assembler = Assembler;
2023
1801
  function _fingerprint(assembly) {
@@ -2151,6 +1929,18 @@ function last(xs) {
2151
1929
  function apply(x, fn) {
2152
1930
  return x !== undefined ? fn(x) : undefined;
2153
1931
  }
1932
+ /**
1933
+ * Return the intersection of two sets
1934
+ */
1935
+ function intersection(xs, ys) {
1936
+ const ret = new Set();
1937
+ for (const x of xs) {
1938
+ if (ys.has(x)) {
1939
+ ret.add(x);
1940
+ }
1941
+ }
1942
+ return ret;
1943
+ }
2154
1944
  /**
2155
1945
  * Return all members names of a JSII interface type
2156
1946
  *
@@ -2181,10 +1971,12 @@ function isInterfaceName(name) {
2181
1971
  function getConstructor(type) {
2182
1972
  return type.symbol.members?.get(ts.InternalSymbolName.Constructor);
2183
1973
  }
2184
- function cmpDesc(a, b, desc) {
2185
- const desc1 = desc(a);
2186
- const desc2 = desc(b);
2187
- return desc1 !== desc2 ? [desc1, desc2] : undefined;
1974
+ function* intersect(xs, ys) {
1975
+ for (const x of xs) {
1976
+ if (ys.has(x)) {
1977
+ yield x;
1978
+ }
1979
+ }
2188
1980
  }
2189
1981
  function noEmptyDict(xs) {
2190
1982
  if (xs == null || Object.keys(xs).length === 0) {
@@ -2368,18 +2160,6 @@ function _findHint(decl, hint) {
2368
2160
  const [node] = ts.getAllJSDocTags(decl, (tag) => tag.tagName.text === hint);
2369
2161
  return node;
2370
2162
  }
2371
- function containsIntersection(type) {
2372
- if (spec.isIntersectionTypeReference(type)) {
2373
- return true;
2374
- }
2375
- if (spec.isUnionTypeReference(type)) {
2376
- return type.union.types.some(containsIntersection);
2377
- }
2378
- if (spec.isCollectionTypeReference(type)) {
2379
- return containsIntersection(type.collection.elementtype);
2380
- }
2381
- return false;
2382
- }
2383
2163
  /**
2384
2164
  * Resolve a Type to Symbol, taking into account single-valued enums which have a bug
2385
2165
  *