@typescript-deploys/pr-build 4.7.0-pr-48294-7 → 4.7.0-pr-48264-4

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.
@@ -14939,6 +14939,10 @@ var ts;
14939
14939
  }
14940
14940
  }
14941
14941
  ts.isAnyImportSyntax = isAnyImportSyntax;
14942
+ function isAnyImportOrBareOrAccessedRequire(node) {
14943
+ return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
14944
+ }
14945
+ ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
14942
14946
  function isLateVisibilityPaintedStatement(node) {
14943
14947
  switch (node.kind) {
14944
14948
  case 265 /* ImportDeclaration */:
@@ -16517,14 +16521,14 @@ var ts;
16517
16521
  }
16518
16522
  ts.isFunctionSymbol = isFunctionSymbol;
16519
16523
  function tryGetModuleSpecifierFromDeclaration(node) {
16520
- var _a, _b, _c;
16524
+ var _a, _b;
16521
16525
  switch (node.kind) {
16522
16526
  case 253 /* VariableDeclaration */:
16523
- return node.initializer.arguments[0].text;
16527
+ return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
16524
16528
  case 265 /* ImportDeclaration */:
16525
- return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text;
16529
+ return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
16526
16530
  case 264 /* ImportEqualsDeclaration */:
16527
- return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text;
16531
+ return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
16528
16532
  default:
16529
16533
  ts.Debug.assertNever(node);
16530
16534
  }
@@ -17051,21 +17055,28 @@ var ts;
17051
17055
  // export = <EntityNameExpression>
17052
17056
  // export default <EntityNameExpression>
17053
17057
  // module.exports = <EntityNameExpression>
17054
- // {<Identifier>}
17055
- // {name: <EntityNameExpression>}
17058
+ // module.exports.x = <EntityNameExpression>
17059
+ // const x = require("...")
17060
+ // const { x } = require("...")
17061
+ // const x = require("...").y
17062
+ // const { x } = require("...").y
17056
17063
  function isAliasSymbolDeclaration(node) {
17057
- return node.kind === 264 /* ImportEqualsDeclaration */ ||
17064
+ if (node.kind === 264 /* ImportEqualsDeclaration */ ||
17058
17065
  node.kind === 263 /* NamespaceExportDeclaration */ ||
17059
17066
  node.kind === 266 /* ImportClause */ && !!node.name ||
17060
17067
  node.kind === 267 /* NamespaceImport */ ||
17061
17068
  node.kind === 273 /* NamespaceExport */ ||
17062
17069
  node.kind === 269 /* ImportSpecifier */ ||
17063
17070
  node.kind === 274 /* ExportSpecifier */ ||
17064
- node.kind === 270 /* ExportAssignment */ && exportAssignmentIsAlias(node) ||
17065
- ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17066
- ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) ||
17067
- node.kind === 296 /* ShorthandPropertyAssignment */ ||
17068
- node.kind === 295 /* PropertyAssignment */ && isAliasableExpression(node.initializer);
17071
+ node.kind === 270 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
17072
+ return true;
17073
+ }
17074
+ return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17075
+ ts.isPropertyAccessExpression(node)
17076
+ && ts.isBinaryExpression(node.parent)
17077
+ && node.parent.left === node
17078
+ && node.parent.operatorToken.kind === 63 /* EqualsToken */
17079
+ && isAliasableExpression(node.parent.right));
17069
17080
  }
17070
17081
  ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
17071
17082
  function getAliasDeclarationFromName(node) {
@@ -17076,6 +17087,7 @@ var ts;
17076
17087
  case 274 /* ExportSpecifier */:
17077
17088
  case 270 /* ExportAssignment */:
17078
17089
  case 264 /* ImportEqualsDeclaration */:
17090
+ case 273 /* NamespaceExport */:
17079
17091
  return node.parent;
17080
17092
  case 160 /* QualifiedName */:
17081
17093
  do {
@@ -39434,6 +39446,13 @@ var ts;
39434
39446
  description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
39435
39447
  defaultValueDescription: false,
39436
39448
  },
39449
+ {
39450
+ name: "noDtsResolution",
39451
+ type: "boolean",
39452
+ affectsModuleResolution: true,
39453
+ category: ts.Diagnostics.Modules,
39454
+ defaultValueDescription: false,
39455
+ },
39437
39456
  // Source Maps
39438
39457
  {
39439
39458
  name: "sourceRoot",
@@ -41813,7 +41832,8 @@ var ts;
41813
41832
  Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
41814
41833
  Extensions[Extensions["Json"] = 2] = "Json";
41815
41834
  Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
41816
- Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */
41835
+ Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
41836
+ Extensions[Extensions["TypeScriptButNotDts"] = 5] = "TypeScriptButNotDts";
41817
41837
  })(Extensions || (Extensions = {}));
41818
41838
  /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
41819
41839
  function resolvedTypeScriptOnly(resolved) {
@@ -42758,7 +42778,21 @@ var ts;
42758
42778
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
42759
42779
  }
42760
42780
  function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
42761
- return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
42781
+ var extensions;
42782
+ if (lookupConfig) {
42783
+ extensions = tsconfigExtensions;
42784
+ }
42785
+ else if (compilerOptions.noDtsResolution) {
42786
+ extensions = [Extensions.TypeScriptButNotDts];
42787
+ if (compilerOptions.allowJs)
42788
+ extensions.push(Extensions.JavaScript);
42789
+ if (compilerOptions.resolveJsonModule)
42790
+ extensions.push(Extensions.Json);
42791
+ }
42792
+ else {
42793
+ extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
42794
+ }
42795
+ return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
42762
42796
  }
42763
42797
  ts.nodeModuleNameResolver = nodeModuleNameResolver;
42764
42798
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
@@ -42767,6 +42801,10 @@ var ts;
42767
42801
  var failedLookupLocations = [];
42768
42802
  // conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
42769
42803
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
42804
+ var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
42805
+ if (compilerOptions.noDtsResolution) {
42806
+ conditions.pop();
42807
+ }
42770
42808
  var state = {
42771
42809
  compilerOptions: compilerOptions,
42772
42810
  host: host,
@@ -42774,7 +42812,7 @@ var ts;
42774
42812
  failedLookupLocations: failedLookupLocations,
42775
42813
  packageJsonInfoCache: cache,
42776
42814
  features: features,
42777
- conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
42815
+ conditions: conditions,
42778
42816
  };
42779
42817
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
42780
42818
  return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
@@ -42982,20 +43020,22 @@ var ts;
42982
43020
  default: return tryExtension(".d.ts" /* Dts */);
42983
43021
  }
42984
43022
  case Extensions.TypeScript:
43023
+ case Extensions.TypeScriptButNotDts:
43024
+ var useDts = extensions === Extensions.TypeScript;
42985
43025
  switch (originalExtension) {
42986
43026
  case ".mjs" /* Mjs */:
42987
43027
  case ".mts" /* Mts */:
42988
43028
  case ".d.mts" /* Dmts */:
42989
- return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
43029
+ return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
42990
43030
  case ".cjs" /* Cjs */:
42991
43031
  case ".cts" /* Cts */:
42992
43032
  case ".d.cts" /* Dcts */:
42993
- return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
43033
+ return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
42994
43034
  case ".json" /* Json */:
42995
43035
  candidate += ".json" /* Json */;
42996
- return tryExtension(".d.ts" /* Dts */);
43036
+ return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
42997
43037
  default:
42998
- return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
43038
+ return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
42999
43039
  }
43000
43040
  case Extensions.JavaScript:
43001
43041
  switch (originalExtension) {
@@ -43213,6 +43253,7 @@ var ts;
43213
43253
  switch (extensions) {
43214
43254
  case Extensions.JavaScript:
43215
43255
  case Extensions.Json:
43256
+ case Extensions.TypeScriptButNotDts:
43216
43257
  packageFile = readPackageJsonMainField(jsonContent, candidate, state);
43217
43258
  break;
43218
43259
  case Extensions.TypeScript:
@@ -43291,6 +43332,8 @@ var ts;
43291
43332
  return extension === ".json" /* Json */;
43292
43333
  case Extensions.TypeScript:
43293
43334
  return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
43335
+ case Extensions.TypeScriptButNotDts:
43336
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */;
43294
43337
  case Extensions.DtsOnly:
43295
43338
  return extension === ".d.ts" /* Dts */;
43296
43339
  }
@@ -54907,7 +54950,7 @@ var ts;
54907
54950
  if (!omitTypeAlias) {
54908
54951
  return errorType;
54909
54952
  }
54910
- return getGlobalTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
54953
+ return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
54911
54954
  }
54912
54955
  var members = ts.createSymbolTable();
54913
54956
  for (var _b = 0, spreadableProperties_1 = spreadableProperties; _b < spreadableProperties_1.length; _b++) {
@@ -55359,7 +55402,7 @@ var ts;
55359
55402
  }
55360
55403
  }
55361
55404
  var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
55362
- type = getUnionType(sourceTypes, 2 /* Subtype */);
55405
+ type = getUnionType(sourceTypes);
55363
55406
  }
55364
55407
  }
55365
55408
  var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
@@ -56674,7 +56717,7 @@ var ts;
56674
56717
  }
56675
56718
  }
56676
56719
  if (memberTypeList.length) {
56677
- var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined, /*aliasMapper*/ undefined);
56720
+ var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined);
56678
56721
  if (enumType_1.flags & 1048576 /* Union */) {
56679
56722
  enumType_1.flags |= 1024 /* EnumLiteral */;
56680
56723
  enumType_1.symbol = symbol;
@@ -59397,7 +59440,7 @@ var ts;
59397
59440
  type.resolvedTypeArguments = source.resolvedTypeArguments;
59398
59441
  return type;
59399
59442
  }
59400
- function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments, aliasMapper) {
59443
+ function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) {
59401
59444
  if (!aliasSymbol) {
59402
59445
  aliasSymbol = getAliasSymbolForTypeNode(node);
59403
59446
  var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
@@ -59409,7 +59452,6 @@ var ts;
59409
59452
  type.mapper = mapper;
59410
59453
  type.aliasSymbol = aliasSymbol;
59411
59454
  type.aliasTypeArguments = aliasTypeArguments;
59412
- type.aliasMapper = aliasMapper;
59413
59455
  return type;
59414
59456
  }
59415
59457
  function getTypeArguments(type) {
@@ -59474,7 +59516,7 @@ var ts;
59474
59516
  }
59475
59517
  return checkNoTypeArguments(node, symbol) ? type : errorType;
59476
59518
  }
59477
- function getGlobalTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) {
59519
+ function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) {
59478
59520
  var type = getDeclaredTypeOfSymbol(symbol);
59479
59521
  if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
59480
59522
  return getStringMappingType(symbol, typeArguments[0]);
@@ -59488,33 +59530,6 @@ var ts;
59488
59530
  }
59489
59531
  return instantiation;
59490
59532
  }
59491
- function getLocalTypeAliasInstantiation(symbol, typeArguments, outerTypeParameterMapper, aliasSymbol, aliasTypeArguments) {
59492
- var type = getDeclaredTypeOfSymbol(symbol);
59493
- if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
59494
- return getStringMappingType(symbol, typeArguments[0]);
59495
- }
59496
- var links = getSymbolLinks(symbol);
59497
- var outerTypeParameters = getOuterTypeParametersOfAlias(symbol);
59498
- var mappedOuterParams = outerTypeParameterMapper && outerTypeParameters && instantiateTypes(outerTypeParameters, outerTypeParameterMapper);
59499
- var typeParameters = links.typeParameters;
59500
- var id = getTypeListId(ts.concatenate(mappedOuterParams, typeArguments)) + getAliasId(aliasSymbol, aliasTypeArguments);
59501
- var instantiation = links.instantiations.get(id);
59502
- if (!instantiation) {
59503
- var outerTypeArgumentMapper = outerTypeParameters && mappedOuterParams && createTypeMapper(outerTypeParameters, mappedOuterParams);
59504
- var argumentMapper = createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration)));
59505
- var combinedMapper = outerTypeArgumentMapper ? combineTypeMappers(argumentMapper, outerTypeArgumentMapper) : argumentMapper;
59506
- links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, combinedMapper, aliasSymbol, aliasTypeArguments));
59507
- }
59508
- return instantiation;
59509
- }
59510
- function getOuterTypeParametersOfAlias(symbol) {
59511
- var _a;
59512
- var links = getSymbolLinks(symbol);
59513
- if (!links.outerTypeParameters) {
59514
- links.outerTypeParameters = ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) && getOuterTypeParameters(symbol.declarations[0], /*includeThisTypes*/ true);
59515
- }
59516
- return links.outerTypeParameters;
59517
- }
59518
59533
  /**
59519
59534
  * Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include
59520
59535
  * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the
@@ -59550,7 +59565,7 @@ var ts;
59550
59565
  // a .d.ts file. See #43622 for an example.
59551
59566
  var aliasSymbol = getAliasSymbolForTypeNode(node);
59552
59567
  var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined;
59553
- return getGlobalTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol));
59568
+ return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol));
59554
59569
  }
59555
59570
  return checkNoTypeArguments(node, symbol) ? type : errorType;
59556
59571
  }
@@ -60465,7 +60480,14 @@ var ts;
60465
60480
  result.types = types;
60466
60481
  return result;
60467
60482
  }
60468
- function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, aliasMapper, origin) {
60483
+ // We sort and deduplicate the constituent types based on object identity. If the subtypeReduction
60484
+ // flag is specified we also reduce the constituent type set to only include types that aren't subtypes
60485
+ // of other types. Subtype reduction is expensive for large union types and is possible only when union
60486
+ // types are known not to circularly reference themselves (as is the case with union types created by
60487
+ // expression constructs such as array literals and the || and ?: operators). Named types can
60488
+ // circularly reference themselves and therefore cannot be subtype reduced during their declaration.
60489
+ // For example, "type Item = string | (() => Item" is a named type that circularly references itself.
60490
+ function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) {
60469
60491
  if (unionReduction === void 0) { unionReduction = 1 /* Literal */; }
60470
60492
  if (types.length === 0) {
60471
60493
  return neverType;
@@ -60534,7 +60556,7 @@ var ts;
60534
60556
  }
60535
60557
  var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
60536
60558
  (includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0);
60537
- return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, aliasMapper, origin);
60559
+ return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
60538
60560
  }
60539
60561
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
60540
60562
  var first;
@@ -60572,7 +60594,7 @@ var ts;
60572
60594
  return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
60573
60595
  }
60574
60596
  // This function assumes the constituent type list is sorted and deduplicated.
60575
- function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments, aliasMapper, origin) {
60597
+ function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments, origin) {
60576
60598
  if (types.length === 0) {
60577
60599
  return neverType;
60578
60600
  }
@@ -60592,7 +60614,6 @@ var ts;
60592
60614
  type.origin = origin;
60593
60615
  type.aliasSymbol = aliasSymbol;
60594
60616
  type.aliasTypeArguments = aliasTypeArguments;
60595
- type.aliasMapper = aliasMapper;
60596
60617
  if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) {
60597
60618
  type.flags |= 16 /* Boolean */;
60598
60619
  type.intrinsicName = "boolean";
@@ -60605,7 +60626,7 @@ var ts;
60605
60626
  var links = getNodeLinks(node);
60606
60627
  if (!links.resolvedType) {
60607
60628
  var aliasSymbol = getAliasSymbolForTypeNode(node);
60608
- links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), /*aliasMapper*/ undefined);
60629
+ links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
60609
60630
  }
60610
60631
  return links.resolvedType;
60611
60632
  }
@@ -60764,16 +60785,25 @@ var ts;
60764
60785
  types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
60765
60786
  return true;
60766
60787
  }
60767
- function createIntersectionType(types, aliasSymbol, aliasTypeArguments, aliasMapper) {
60788
+ function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
60768
60789
  var result = createType(2097152 /* Intersection */);
60769
60790
  result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
60770
60791
  result.types = types;
60771
60792
  result.aliasSymbol = aliasSymbol;
60772
60793
  result.aliasTypeArguments = aliasTypeArguments;
60773
- result.aliasMapper = aliasMapper;
60774
60794
  return result;
60775
60795
  }
60776
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments, aliasMapper) {
60796
+ // We normalize combinations of intersection and union types based on the distributive property of the '&'
60797
+ // operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
60798
+ // types with union type constituents into equivalent union types with intersection type constituents and
60799
+ // effectively ensure that union types are always at the top level in type representations.
60800
+ //
60801
+ // We do not perform structural deduplication on intersection types. Intersection types are created only by the &
60802
+ // type operator and we can't reduce those because we want to support recursive intersection types. For example,
60803
+ // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
60804
+ // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
60805
+ // for intersections of types with signatures can be deterministic.
60806
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
60777
60807
  var typeMembershipMap = new ts.Map();
60778
60808
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
60779
60809
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -60833,16 +60863,16 @@ var ts;
60833
60863
  // When the intersection creates a reduced set (which might mean that *all* union types have
60834
60864
  // disappeared), we restart the operation to get a new set of combined flags. Once we have
60835
60865
  // reduced we'll never reduce again, so this occurs at most once.
60836
- result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments, aliasMapper);
60866
+ result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
60837
60867
  }
60838
60868
  else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
60839
60869
  var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType;
60840
60870
  removeFromEach(typeSet, 32768 /* Undefined */);
60841
- result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper);
60871
+ result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60842
60872
  }
60843
60873
  else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
60844
60874
  removeFromEach(typeSet, 65536 /* Null */);
60845
- result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper);
60875
+ result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60846
60876
  }
60847
60877
  else {
60848
60878
  // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of
@@ -60855,7 +60885,7 @@ var ts;
60855
60885
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
60856
60886
  // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
60857
60887
  var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
60858
- result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper, origin);
60888
+ result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
60859
60889
  }
60860
60890
  }
60861
60891
  else {
@@ -60901,7 +60931,7 @@ var ts;
60901
60931
  var links = getNodeLinks(node);
60902
60932
  if (!links.resolvedType) {
60903
60933
  var aliasSymbol = getAliasSymbolForTypeNode(node);
60904
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), /*aliasMapper*/ undefined);
60934
+ links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
60905
60935
  }
60906
60936
  return links.resolvedType;
60907
60937
  }
@@ -61020,7 +61050,7 @@ var ts;
61020
61050
  var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ?
61021
61051
  info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; });
61022
61052
  return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
61023
- /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, /*aliasMapper*/ undefined, origin);
61053
+ /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
61024
61054
  }
61025
61055
  /**
61026
61056
  * A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
@@ -61053,7 +61083,7 @@ var ts;
61053
61083
  return type;
61054
61084
  }
61055
61085
  var extractTypeAlias = getGlobalExtractSymbol();
61056
- return extractTypeAlias ? getGlobalTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
61086
+ return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
61057
61087
  }
61058
61088
  function getIndexTypeOrString(type) {
61059
61089
  var indexType = getExtractStringType(getIndexType(type));
@@ -61183,14 +61213,13 @@ var ts;
61183
61213
  result.type = type;
61184
61214
  return result;
61185
61215
  }
61186
- function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments, aliasMapper) {
61216
+ function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) {
61187
61217
  var type = createType(8388608 /* IndexedAccess */);
61188
61218
  type.objectType = objectType;
61189
61219
  type.indexType = indexType;
61190
61220
  type.accessFlags = accessFlags;
61191
61221
  type.aliasSymbol = aliasSymbol;
61192
61222
  type.aliasTypeArguments = aliasTypeArguments;
61193
- type.aliasMapper = aliasMapper;
61194
61223
  return type;
61195
61224
  }
61196
61225
  /**
@@ -61548,9 +61577,9 @@ var ts;
61548
61577
  var templateMapper = combineTypeMappers(objectType.mapper, mapper);
61549
61578
  return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
61550
61579
  }
61551
- function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments, aliasMapper) {
61580
+ function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
61552
61581
  if (accessFlags === void 0) { accessFlags = 0 /* None */; }
61553
- return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments, aliasMapper) || (accessNode ? errorType : unknownType);
61582
+ return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
61554
61583
  }
61555
61584
  function indexTypeLessThan(indexType, limit) {
61556
61585
  return everyType(indexType, function (t) {
@@ -61564,7 +61593,7 @@ var ts;
61564
61593
  return false;
61565
61594
  });
61566
61595
  }
61567
- function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments, aliasMapper) {
61596
+ function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
61568
61597
  if (accessFlags === void 0) { accessFlags = 0 /* None */; }
61569
61598
  if (objectType === wildcardType || indexType === wildcardType) {
61570
61599
  return wildcardType;
@@ -61595,7 +61624,7 @@ var ts;
61595
61624
  var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments);
61596
61625
  var type = indexedAccessTypes.get(id);
61597
61626
  if (!type) {
61598
- indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments, aliasMapper));
61627
+ indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments));
61599
61628
  }
61600
61629
  return type;
61601
61630
  }
@@ -61625,8 +61654,8 @@ var ts;
61625
61654
  return undefined;
61626
61655
  }
61627
61656
  return accessFlags & 4 /* Writing */
61628
- ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments, aliasMapper)
61629
- : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper);
61657
+ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments)
61658
+ : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments);
61630
61659
  }
61631
61660
  return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */);
61632
61661
  }
@@ -61636,7 +61665,7 @@ var ts;
61636
61665
  var objectType = getTypeFromTypeNode(node.objectType);
61637
61666
  var indexType = getTypeFromTypeNode(node.indexType);
61638
61667
  var potentialAlias = getAliasSymbolForTypeNode(node);
61639
- var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias), /*aliasMapper*/ undefined);
61668
+ var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
61640
61669
  links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ &&
61641
61670
  resolved.objectType === objectType &&
61642
61671
  resolved.indexType === indexType ?
@@ -61803,7 +61832,6 @@ var ts;
61803
61832
  result.combinedMapper = combinedMapper;
61804
61833
  result.aliasSymbol = aliasSymbol || root.aliasSymbol;
61805
61834
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
61806
- result.aliasMapper = result.aliasSymbol ? mapper : undefined;
61807
61835
  return "break";
61808
61836
  };
61809
61837
  // We loop here for an immediately nested conditional type in the false position, effectively treating
@@ -62599,7 +62627,7 @@ var ts;
62599
62627
  var result = target.instantiations.get(id);
62600
62628
  if (!result) {
62601
62629
  var newMapper = createTypeMapper(typeParameters, typeArguments);
62602
- result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments, mapper) :
62630
+ result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) :
62603
62631
  target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) :
62604
62632
  instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
62605
62633
  target.instantiations.set(id, result);
@@ -62688,7 +62716,7 @@ var ts;
62688
62716
  return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
62689
62717
  }
62690
62718
  return t;
62691
- }, aliasSymbol, aliasTypeArguments, mapper);
62719
+ }, aliasSymbol, aliasTypeArguments);
62692
62720
  }
62693
62721
  }
62694
62722
  // If the constraint type of the instantiation is the wildcard type, return the wildcard type.
@@ -62757,7 +62785,6 @@ var ts;
62757
62785
  result.mapper = mapper;
62758
62786
  result.aliasSymbol = aliasSymbol || type.aliasSymbol;
62759
62787
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
62760
- result.aliasMapper = mapper;
62761
62788
  return result;
62762
62789
  }
62763
62790
  function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
@@ -62777,7 +62804,7 @@ var ts;
62777
62804
  // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the
62778
62805
  // result is (A extends U ? X : Y) | (B extends U ? X : Y).
62779
62806
  result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ?
62780
- mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments, mapper) :
62807
+ mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) :
62781
62808
  getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments);
62782
62809
  root.instantiations.set(id, result);
62783
62810
  }
@@ -62837,8 +62864,8 @@ var ts;
62837
62864
  var newAliasSymbol = aliasSymbol || type.aliasSymbol;
62838
62865
  var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
62839
62866
  return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ?
62840
- getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments, mapper) :
62841
- getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments, mapper);
62867
+ getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) :
62868
+ getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments);
62842
62869
  }
62843
62870
  if (flags & 4194304 /* Index */) {
62844
62871
  return getIndexType(instantiateType(type.type, mapper));
@@ -62852,7 +62879,7 @@ var ts;
62852
62879
  if (flags & 8388608 /* IndexedAccess */) {
62853
62880
  var newAliasSymbol = aliasSymbol || type.aliasSymbol;
62854
62881
  var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
62855
- return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments, mapper);
62882
+ return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments);
62856
62883
  }
62857
62884
  if (flags & 16777216 /* Conditional */) {
62858
62885
  return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
@@ -64846,10 +64873,7 @@ var ts;
64846
64873
  if (variances === ts.emptyArray) {
64847
64874
  return 1 /* Unknown */;
64848
64875
  }
64849
- var outerTypeParameters = getOuterTypeParametersOfAlias(source.aliasSymbol);
64850
- var sourceArgs = outerTypeParameters && source.aliasMapper ? ts.concatenate(source.aliasTypeArguments, instantiateTypes(outerTypeParameters, source.aliasMapper)) : source.aliasTypeArguments;
64851
- var targetArgs = outerTypeParameters && target.aliasMapper ? ts.concatenate(target.aliasTypeArguments, instantiateTypes(outerTypeParameters, target.aliasMapper)) : target.aliasTypeArguments;
64852
- var varianceResult = relateVariances(sourceArgs, targetArgs, variances, intersectionState);
64876
+ var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
64853
64877
  if (varianceResult !== undefined) {
64854
64878
  return varianceResult;
64855
64879
  }
@@ -66138,11 +66162,8 @@ var ts;
66138
66162
  }
66139
66163
  function getAliasVariances(symbol) {
66140
66164
  var links = getSymbolLinks(symbol);
66141
- // outer type parameter aliases are last so they can be easily ignored by, eg, inference
66142
- var params = ts.concatenate(links.typeParameters, getOuterTypeParametersOfAlias(symbol));
66143
- return getVariancesWorker(params, links, function (_links, param, marker) {
66144
- var mapper = makeUnaryTypeMapper(param, marker);
66145
- var type = getLocalTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, mapper), mapper);
66165
+ return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
66166
+ var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
66146
66167
  type.aliasTypeArgumentsContainsMarker = true;
66147
66168
  return type;
66148
66169
  });
@@ -66799,7 +66820,7 @@ var ts;
66799
66820
  }
66800
66821
  // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
66801
66822
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
66802
- getGlobalTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
66823
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
66803
66824
  reducedType;
66804
66825
  }
66805
66826
  function getNonNullableType(type) {
@@ -69025,7 +69046,7 @@ var ts;
69025
69046
  newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered);
69026
69047
  }
69027
69048
  }
69028
- return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, /*aliasMapper*/ undefined, newOrigin);
69049
+ return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin);
69029
69050
  }
69030
69051
  return type.flags & 131072 /* Never */ || f(type) ? type : neverType;
69031
69052
  }
@@ -69061,9 +69082,9 @@ var ts;
69061
69082
  }
69062
69083
  return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
69063
69084
  }
69064
- function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments, aliasMapper) {
69085
+ function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
69065
69086
  return type.flags & 1048576 /* Union */ && aliasSymbol ?
69066
- getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper) :
69087
+ getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
69067
69088
  mapType(type, mapper);
69068
69089
  }
69069
69090
  function extractTypesOfKind(type, kind) {
@@ -72248,7 +72269,7 @@ var ts;
72248
72269
  var params = getSymbolLinks(managedSym).typeParameters;
72249
72270
  if (ts.length(params) >= 2) {
72250
72271
  var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context));
72251
- return getGlobalTypeAliasInstantiation(managedSym, args);
72272
+ return getTypeAliasInstantiation(managedSym, args);
72252
72273
  }
72253
72274
  }
72254
72275
  if (ts.length(declaredManagedType.typeParameters) >= 2) {
@@ -80392,7 +80413,7 @@ var ts;
80392
80413
  if (awaitedSymbol) {
80393
80414
  // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
80394
80415
  // an `Awaited<T | U>` would suffice.
80395
- return getGlobalTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
80416
+ return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
80396
80417
  }
80397
80418
  }
80398
80419
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typescript-deploys/pr-build",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.7.0-pr-48294-7",
5
+ "version": "4.7.0-pr-48264-4",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [