typescript 4.9.0-dev.20221021 → 4.9.0-dev.20221022

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.
@@ -108,7 +108,7 @@ var ts;
108
108
  // The following is baselined as a literal template type without intervention
109
109
  /** The version of the TypeScript compiler release */
110
110
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
111
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221021");
111
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221022");
112
112
  /* @internal */
113
113
  var Comparison;
114
114
  (function (Comparison) {
@@ -1900,8 +1900,8 @@ var ts;
1900
1900
  return compareValues(a === null || a === void 0 ? void 0 : a.start, b === null || b === void 0 ? void 0 : b.start) || compareValues(a === null || a === void 0 ? void 0 : a.length, b === null || b === void 0 ? void 0 : b.length);
1901
1901
  }
1902
1902
  ts.compareTextSpans = compareTextSpans;
1903
- function min(a, b, compare) {
1904
- return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b;
1903
+ function min(items, compare) {
1904
+ return reduceLeft(items, function (x, y) { return compare(x, y) === -1 /* Comparison.LessThan */ ? x : y; });
1905
1905
  }
1906
1906
  ts.min = min;
1907
1907
  /**
@@ -5118,8 +5118,8 @@ var ts;
5118
5118
  NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance";
5119
5119
  NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic";
5120
5120
  NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked";
5121
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper";
5122
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding";
5121
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAccessInAsync"] = 2048] = "MethodWithSuperPropertyAccessInAsync";
5122
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAssignmentInAsync"] = 4096] = "MethodWithSuperPropertyAssignmentInAsync";
5123
5123
  NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments";
5124
5124
  NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed";
5125
5125
  NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass";
@@ -73684,12 +73684,17 @@ var ts;
73684
73684
  var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true);
73685
73685
  var container = immediateContainer;
73686
73686
  var needToCaptureLexicalThis = false;
73687
+ var inAsyncFunction = false;
73687
73688
  // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
73688
73689
  if (!isCallExpression) {
73689
73690
  while (container && container.kind === 216 /* SyntaxKind.ArrowFunction */) {
73691
+ if (ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73692
+ inAsyncFunction = true;
73690
73693
  container = ts.getSuperContainer(container, /*stopOnFunctions*/ true);
73691
73694
  needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */;
73692
73695
  }
73696
+ if (container && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73697
+ inAsyncFunction = true;
73693
73698
  }
73694
73699
  var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
73695
73700
  var nodeCheckFlag = 0;
@@ -73795,12 +73800,12 @@ var ts;
73795
73800
  // as a call expression cannot be used as the target of a destructuring assignment while a property access can.
73796
73801
  //
73797
73802
  // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations.
73798
- if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */)) {
73803
+ if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && inAsyncFunction) {
73799
73804
  if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
73800
- getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */;
73805
+ getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */;
73801
73806
  }
73802
73807
  else {
73803
- getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */;
73808
+ getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */;
73804
73809
  }
73805
73810
  }
73806
73811
  if (needToCaptureLexicalThis) {
@@ -82956,7 +82961,7 @@ var ts;
82956
82961
  return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
82957
82962
  }
82958
82963
  // primitives with a `{ then() }` won't be unwrapped/adopted.
82959
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82964
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82960
82965
  return undefined;
82961
82966
  }
82962
82967
  var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217
@@ -83023,7 +83028,7 @@ var ts;
83023
83028
  * Determines whether a type is an object with a callable `then` member.
83024
83029
  */
83025
83030
  function isThenableType(type) {
83026
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
83031
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
83027
83032
  // primitive types cannot be considered "thenable" since they are not objects.
83028
83033
  return false;
83029
83034
  }
@@ -98522,8 +98527,11 @@ var ts;
98522
98527
  }
98523
98528
  return ts.visitEachChild(node, visitor, context);
98524
98529
  case 174 /* SyntaxKind.GetAccessor */:
98530
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitGetAccessorDeclaration, node);
98525
98531
  case 175 /* SyntaxKind.SetAccessor */:
98532
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitSetAccessorDeclaration, node);
98526
98533
  case 173 /* SyntaxKind.Constructor */:
98534
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitConstructorDeclaration, node);
98527
98535
  case 260 /* SyntaxKind.ClassDeclaration */:
98528
98536
  case 228 /* SyntaxKind.ClassExpression */:
98529
98537
  return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node);
@@ -98624,6 +98632,9 @@ var ts;
98624
98632
  return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
98625
98633
  /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
98626
98634
  }
98635
+ function visitConstructorDeclaration(node) {
98636
+ return factory.updateConstructorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98637
+ }
98627
98638
  /**
98628
98639
  * Visits a MethodDeclaration node.
98629
98640
  *
@@ -98638,7 +98649,14 @@ var ts;
98638
98649
  /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
98639
98650
  /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
98640
98651
  ? transformAsyncFunctionBody(node)
98641
- : ts.visitFunctionBody(node.body, visitor, context));
98652
+ : transformMethodBody(node));
98653
+ }
98654
+ function visitGetAccessorDeclaration(node) {
98655
+ return factory.updateGetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context),
98656
+ /*type*/ undefined, transformMethodBody(node));
98657
+ }
98658
+ function visitSetAccessorDeclaration(node) {
98659
+ return factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98642
98660
  }
98643
98661
  /**
98644
98662
  * Visits a FunctionDeclaration node.
@@ -98752,6 +98770,42 @@ var ts;
98752
98770
  }
98753
98771
  return false;
98754
98772
  }
98773
+ function transformMethodBody(node) {
98774
+ ts.Debug.assertIsDefined(node.body);
98775
+ var savedCapturedSuperProperties = capturedSuperProperties;
98776
+ var savedHasSuperElementAccess = hasSuperElementAccess;
98777
+ capturedSuperProperties = new ts.Set();
98778
+ hasSuperElementAccess = false;
98779
+ var updated = ts.visitFunctionBody(node.body, visitor, context);
98780
+ // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98781
+ // This step isn't needed if we eventually transform this to ES5.
98782
+ var originalMethod = ts.getOriginalNode(node, ts.isFunctionLikeDeclaration);
98783
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ &&
98784
+ resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) &&
98785
+ (ts.getFunctionFlags(originalMethod) & 3 /* FunctionFlags.AsyncGenerator */) !== 3 /* FunctionFlags.AsyncGenerator */;
98786
+ if (emitSuperHelpers) {
98787
+ enableSubstitutionForAsyncMethodsWithSuper();
98788
+ if (capturedSuperProperties.size) {
98789
+ var variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
98790
+ substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
98791
+ var statements = updated.statements.slice();
98792
+ ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
98793
+ updated = factory.updateBlock(updated, statements);
98794
+ }
98795
+ if (hasSuperElementAccess) {
98796
+ // Emit helpers for super element access expressions (`super[x]`).
98797
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98798
+ ts.addEmitHelper(updated, ts.advancedAsyncSuperHelper);
98799
+ }
98800
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98801
+ ts.addEmitHelper(updated, ts.asyncSuperHelper);
98802
+ }
98803
+ }
98804
+ }
98805
+ capturedSuperProperties = savedCapturedSuperProperties;
98806
+ hasSuperElementAccess = savedHasSuperElementAccess;
98807
+ return updated;
98808
+ }
98755
98809
  function transformAsyncFunctionBody(node) {
98756
98810
  resumeLexicalEnvironment();
98757
98811
  var original = ts.getOriginalNode(node, ts.isFunctionLike);
@@ -98784,7 +98838,7 @@ var ts;
98784
98838
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
98785
98839
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98786
98840
  // This step isn't needed if we eventually transform this to ES5.
98787
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
98841
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
98788
98842
  if (emitSuperHelpers) {
98789
98843
  enableSubstitutionForAsyncMethodsWithSuper();
98790
98844
  if (capturedSuperProperties.size) {
@@ -98797,10 +98851,10 @@ var ts;
98797
98851
  ts.setTextRange(block, node.body);
98798
98852
  if (emitSuperHelpers && hasSuperElementAccess) {
98799
98853
  // Emit helpers for super element access expressions (`super[x]`).
98800
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
98854
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98801
98855
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
98802
98856
  }
98803
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
98857
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98804
98858
  ts.addEmitHelper(block, ts.asyncSuperHelper);
98805
98859
  }
98806
98860
  }
@@ -98872,7 +98926,7 @@ var ts;
98872
98926
  // If we need to support substitutions for `super` in an async method,
98873
98927
  // we should track it here.
98874
98928
  if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
98875
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
98929
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
98876
98930
  if (superContainerFlags !== enclosingSuperContainerFlags) {
98877
98931
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
98878
98932
  enclosingSuperContainerFlags = superContainerFlags;
@@ -98949,7 +99003,7 @@ var ts;
98949
99003
  || kind === 175 /* SyntaxKind.SetAccessor */;
98950
99004
  }
98951
99005
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
98952
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99006
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98953
99007
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
98954
99008
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
98955
99009
  }
@@ -98964,7 +99018,7 @@ var ts;
98964
99018
  function createSuperAccessVariableStatement(factory, resolver, node, names) {
98965
99019
  // Create a variable declaration with a getter/setter (if binding) definition for each name:
98966
99020
  // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
98967
- var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0;
99021
+ var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) !== 0;
98968
99022
  var accessors = [];
98969
99023
  names.forEach(function (_, key) {
98970
99024
  var name = ts.unescapeLeadingUnderscores(key);
@@ -99672,7 +99726,7 @@ var ts;
99672
99726
  /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */)));
99673
99727
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
99674
99728
  // This step isn't needed if we eventually transform this to ES5.
99675
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
99729
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
99676
99730
  if (emitSuperHelpers) {
99677
99731
  enableSubstitutionForAsyncMethodsWithSuper();
99678
99732
  var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
@@ -99683,10 +99737,10 @@ var ts;
99683
99737
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
99684
99738
  var block = factory.updateBlock(node.body, statements);
99685
99739
  if (emitSuperHelpers && hasSuperElementAccess) {
99686
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99740
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99687
99741
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
99688
99742
  }
99689
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
99743
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
99690
99744
  ts.addEmitHelper(block, ts.asyncSuperHelper);
99691
99745
  }
99692
99746
  }
@@ -99815,7 +99869,7 @@ var ts;
99815
99869
  // If we need to support substitutions for `super` in an async method,
99816
99870
  // we should track it here.
99817
99871
  if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
99818
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
99872
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
99819
99873
  if (superContainerFlags !== enclosingSuperContainerFlags) {
99820
99874
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
99821
99875
  enclosingSuperContainerFlags = superContainerFlags;
@@ -99892,7 +99946,7 @@ var ts;
99892
99946
  || kind === 175 /* SyntaxKind.SetAccessor */;
99893
99947
  }
99894
99948
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
99895
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99949
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99896
99950
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"),
99897
99951
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
99898
99952
  }
@@ -123918,7 +123972,7 @@ var ts;
123918
123972
  var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */;
123919
123973
  if (isNonDirectorySeparatorRoot &&
123920
123974
  dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
123921
- pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart
123975
+ pathPartForUserCheck.search(/[a-zA-Z]\$\//) === 0) { // Dos style nextPart
123922
123976
  nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
123923
123977
  if (nextDirectorySeparator === -1) {
123924
123978
  // ignore "//vda1cs4850/c$/folderAtRoot"
@@ -125424,15 +125478,21 @@ var ts;
125424
125478
  return undefined;
125425
125479
  }
125426
125480
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
125427
- var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125428
- if (normalizedTargetPath === undefined) {
125481
+ var normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125482
+ if (normalizedTargetPaths === undefined) {
125483
+ return undefined;
125484
+ }
125485
+ var normalizedSourcePaths = getPathsRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125486
+ var relativePaths = ts.flatMap(normalizedSourcePaths, function (sourcePath) {
125487
+ return ts.map(normalizedTargetPaths, function (targetPath) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourcePath, targetPath, getCanonicalFileName)); });
125488
+ });
125489
+ var shortest = ts.min(relativePaths, ts.compareNumberOfDirectorySeparators);
125490
+ if (!shortest) {
125429
125491
  return undefined;
125430
125492
  }
125431
- var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125432
- var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
125433
125493
  return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
125434
- ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
125435
- : ts.removeFileExtension(relativePath);
125494
+ ? removeExtensionAndIndexPostFix(shortest, ending, compilerOptions)
125495
+ : ts.removeFileExtension(shortest);
125436
125496
  }
125437
125497
  function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
125438
125498
  var path = _a.path, isRedirect = _a.isRedirect;
@@ -125569,8 +125629,8 @@ var ts;
125569
125629
  }
125570
125630
  }
125571
125631
  }
125572
- function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125573
- return ts.firstDefined(rootDirs, function (rootDir) {
125632
+ function getPathsRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125633
+ return ts.mapDefined(rootDirs, function (rootDir) {
125574
125634
  var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
125575
125635
  return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
125576
125636
  });
@@ -146079,7 +146139,7 @@ var ts;
146079
146139
  return bestMatch;
146080
146140
  }
146081
146141
  function betterMatch(a, b) {
146082
- return ts.min(a, b, compareMatches);
146142
+ return ts.min([a, b], compareMatches);
146083
146143
  }
146084
146144
  function compareMatches(a, b) {
146085
146145
  return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */
package/lib/typescript.js CHANGED
@@ -99,7 +99,7 @@ var ts;
99
99
  // The following is baselined as a literal template type without intervention
100
100
  /** The version of the TypeScript compiler release */
101
101
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
102
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221021");
102
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221022");
103
103
  /* @internal */
104
104
  var Comparison;
105
105
  (function (Comparison) {
@@ -1891,8 +1891,8 @@ var ts;
1891
1891
  return compareValues(a === null || a === void 0 ? void 0 : a.start, b === null || b === void 0 ? void 0 : b.start) || compareValues(a === null || a === void 0 ? void 0 : a.length, b === null || b === void 0 ? void 0 : b.length);
1892
1892
  }
1893
1893
  ts.compareTextSpans = compareTextSpans;
1894
- function min(a, b, compare) {
1895
- return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b;
1894
+ function min(items, compare) {
1895
+ return reduceLeft(items, function (x, y) { return compare(x, y) === -1 /* Comparison.LessThan */ ? x : y; });
1896
1896
  }
1897
1897
  ts.min = min;
1898
1898
  /**
@@ -5109,8 +5109,8 @@ var ts;
5109
5109
  NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance";
5110
5110
  NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic";
5111
5111
  NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked";
5112
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper";
5113
- NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding";
5112
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAccessInAsync"] = 2048] = "MethodWithSuperPropertyAccessInAsync";
5113
+ NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAssignmentInAsync"] = 4096] = "MethodWithSuperPropertyAssignmentInAsync";
5114
5114
  NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments";
5115
5115
  NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed";
5116
5116
  NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass";
@@ -73675,12 +73675,17 @@ var ts;
73675
73675
  var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true);
73676
73676
  var container = immediateContainer;
73677
73677
  var needToCaptureLexicalThis = false;
73678
+ var inAsyncFunction = false;
73678
73679
  // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
73679
73680
  if (!isCallExpression) {
73680
73681
  while (container && container.kind === 216 /* SyntaxKind.ArrowFunction */) {
73682
+ if (ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73683
+ inAsyncFunction = true;
73681
73684
  container = ts.getSuperContainer(container, /*stopOnFunctions*/ true);
73682
73685
  needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */;
73683
73686
  }
73687
+ if (container && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
73688
+ inAsyncFunction = true;
73684
73689
  }
73685
73690
  var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
73686
73691
  var nodeCheckFlag = 0;
@@ -73786,12 +73791,12 @@ var ts;
73786
73791
  // as a call expression cannot be used as the target of a destructuring assignment while a property access can.
73787
73792
  //
73788
73793
  // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations.
73789
- if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */)) {
73794
+ if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && inAsyncFunction) {
73790
73795
  if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
73791
- getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */;
73796
+ getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */;
73792
73797
  }
73793
73798
  else {
73794
- getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */;
73799
+ getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */;
73795
73800
  }
73796
73801
  }
73797
73802
  if (needToCaptureLexicalThis) {
@@ -82947,7 +82952,7 @@ var ts;
82947
82952
  return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
82948
82953
  }
82949
82954
  // primitives with a `{ then() }` won't be unwrapped/adopted.
82950
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82955
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
82951
82956
  return undefined;
82952
82957
  }
82953
82958
  var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217
@@ -83014,7 +83019,7 @@ var ts;
83014
83019
  * Determines whether a type is an object with a callable `then` member.
83015
83020
  */
83016
83021
  function isThenableType(type) {
83017
- if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
83022
+ if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
83018
83023
  // primitive types cannot be considered "thenable" since they are not objects.
83019
83024
  return false;
83020
83025
  }
@@ -98513,8 +98518,11 @@ var ts;
98513
98518
  }
98514
98519
  return ts.visitEachChild(node, visitor, context);
98515
98520
  case 174 /* SyntaxKind.GetAccessor */:
98521
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitGetAccessorDeclaration, node);
98516
98522
  case 175 /* SyntaxKind.SetAccessor */:
98523
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitSetAccessorDeclaration, node);
98517
98524
  case 173 /* SyntaxKind.Constructor */:
98525
+ return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitConstructorDeclaration, node);
98518
98526
  case 260 /* SyntaxKind.ClassDeclaration */:
98519
98527
  case 228 /* SyntaxKind.ClassExpression */:
98520
98528
  return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node);
@@ -98615,6 +98623,9 @@ var ts;
98615
98623
  return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
98616
98624
  /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
98617
98625
  }
98626
+ function visitConstructorDeclaration(node) {
98627
+ return factory.updateConstructorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98628
+ }
98618
98629
  /**
98619
98630
  * Visits a MethodDeclaration node.
98620
98631
  *
@@ -98629,7 +98640,14 @@ var ts;
98629
98640
  /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
98630
98641
  /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
98631
98642
  ? transformAsyncFunctionBody(node)
98632
- : ts.visitFunctionBody(node.body, visitor, context));
98643
+ : transformMethodBody(node));
98644
+ }
98645
+ function visitGetAccessorDeclaration(node) {
98646
+ return factory.updateGetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context),
98647
+ /*type*/ undefined, transformMethodBody(node));
98648
+ }
98649
+ function visitSetAccessorDeclaration(node) {
98650
+ return factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
98633
98651
  }
98634
98652
  /**
98635
98653
  * Visits a FunctionDeclaration node.
@@ -98743,6 +98761,42 @@ var ts;
98743
98761
  }
98744
98762
  return false;
98745
98763
  }
98764
+ function transformMethodBody(node) {
98765
+ ts.Debug.assertIsDefined(node.body);
98766
+ var savedCapturedSuperProperties = capturedSuperProperties;
98767
+ var savedHasSuperElementAccess = hasSuperElementAccess;
98768
+ capturedSuperProperties = new ts.Set();
98769
+ hasSuperElementAccess = false;
98770
+ var updated = ts.visitFunctionBody(node.body, visitor, context);
98771
+ // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98772
+ // This step isn't needed if we eventually transform this to ES5.
98773
+ var originalMethod = ts.getOriginalNode(node, ts.isFunctionLikeDeclaration);
98774
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ &&
98775
+ resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) &&
98776
+ (ts.getFunctionFlags(originalMethod) & 3 /* FunctionFlags.AsyncGenerator */) !== 3 /* FunctionFlags.AsyncGenerator */;
98777
+ if (emitSuperHelpers) {
98778
+ enableSubstitutionForAsyncMethodsWithSuper();
98779
+ if (capturedSuperProperties.size) {
98780
+ var variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
98781
+ substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
98782
+ var statements = updated.statements.slice();
98783
+ ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
98784
+ updated = factory.updateBlock(updated, statements);
98785
+ }
98786
+ if (hasSuperElementAccess) {
98787
+ // Emit helpers for super element access expressions (`super[x]`).
98788
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98789
+ ts.addEmitHelper(updated, ts.advancedAsyncSuperHelper);
98790
+ }
98791
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98792
+ ts.addEmitHelper(updated, ts.asyncSuperHelper);
98793
+ }
98794
+ }
98795
+ }
98796
+ capturedSuperProperties = savedCapturedSuperProperties;
98797
+ hasSuperElementAccess = savedHasSuperElementAccess;
98798
+ return updated;
98799
+ }
98746
98800
  function transformAsyncFunctionBody(node) {
98747
98801
  resumeLexicalEnvironment();
98748
98802
  var original = ts.getOriginalNode(node, ts.isFunctionLike);
@@ -98775,7 +98829,7 @@ var ts;
98775
98829
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
98776
98830
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
98777
98831
  // This step isn't needed if we eventually transform this to ES5.
98778
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
98832
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
98779
98833
  if (emitSuperHelpers) {
98780
98834
  enableSubstitutionForAsyncMethodsWithSuper();
98781
98835
  if (capturedSuperProperties.size) {
@@ -98788,10 +98842,10 @@ var ts;
98788
98842
  ts.setTextRange(block, node.body);
98789
98843
  if (emitSuperHelpers && hasSuperElementAccess) {
98790
98844
  // Emit helpers for super element access expressions (`super[x]`).
98791
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
98845
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98792
98846
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
98793
98847
  }
98794
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
98848
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
98795
98849
  ts.addEmitHelper(block, ts.asyncSuperHelper);
98796
98850
  }
98797
98851
  }
@@ -98863,7 +98917,7 @@ var ts;
98863
98917
  // If we need to support substitutions for `super` in an async method,
98864
98918
  // we should track it here.
98865
98919
  if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
98866
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
98920
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
98867
98921
  if (superContainerFlags !== enclosingSuperContainerFlags) {
98868
98922
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
98869
98923
  enclosingSuperContainerFlags = superContainerFlags;
@@ -98940,7 +98994,7 @@ var ts;
98940
98994
  || kind === 175 /* SyntaxKind.SetAccessor */;
98941
98995
  }
98942
98996
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
98943
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
98997
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
98944
98998
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
98945
98999
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
98946
99000
  }
@@ -98955,7 +99009,7 @@ var ts;
98955
99009
  function createSuperAccessVariableStatement(factory, resolver, node, names) {
98956
99010
  // Create a variable declaration with a getter/setter (if binding) definition for each name:
98957
99011
  // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
98958
- var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0;
99012
+ var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) !== 0;
98959
99013
  var accessors = [];
98960
99014
  names.forEach(function (_, key) {
98961
99015
  var name = ts.unescapeLeadingUnderscores(key);
@@ -99663,7 +99717,7 @@ var ts;
99663
99717
  /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */)));
99664
99718
  // Minor optimization, emit `_super` helper to capture `super` access in an arrow.
99665
99719
  // This step isn't needed if we eventually transform this to ES5.
99666
- var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */);
99720
+ var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
99667
99721
  if (emitSuperHelpers) {
99668
99722
  enableSubstitutionForAsyncMethodsWithSuper();
99669
99723
  var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
@@ -99674,10 +99728,10 @@ var ts;
99674
99728
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
99675
99729
  var block = factory.updateBlock(node.body, statements);
99676
99730
  if (emitSuperHelpers && hasSuperElementAccess) {
99677
- if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99731
+ if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99678
99732
  ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
99679
99733
  }
99680
- else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) {
99734
+ else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
99681
99735
  ts.addEmitHelper(block, ts.asyncSuperHelper);
99682
99736
  }
99683
99737
  }
@@ -99806,7 +99860,7 @@ var ts;
99806
99860
  // If we need to support substitutions for `super` in an async method,
99807
99861
  // we should track it here.
99808
99862
  if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
99809
- var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */);
99863
+ var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
99810
99864
  if (superContainerFlags !== enclosingSuperContainerFlags) {
99811
99865
  var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
99812
99866
  enclosingSuperContainerFlags = superContainerFlags;
@@ -99883,7 +99937,7 @@ var ts;
99883
99937
  || kind === 175 /* SyntaxKind.SetAccessor */;
99884
99938
  }
99885
99939
  function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
99886
- if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) {
99940
+ if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
99887
99941
  return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"),
99888
99942
  /*typeArguments*/ undefined, [argumentExpression]), "value"), location);
99889
99943
  }
@@ -123909,7 +123963,7 @@ var ts;
123909
123963
  var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */;
123910
123964
  if (isNonDirectorySeparatorRoot &&
123911
123965
  dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
123912
- pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart
123966
+ pathPartForUserCheck.search(/[a-zA-Z]\$\//) === 0) { // Dos style nextPart
123913
123967
  nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
123914
123968
  if (nextDirectorySeparator === -1) {
123915
123969
  // ignore "//vda1cs4850/c$/folderAtRoot"
@@ -125415,15 +125469,21 @@ var ts;
125415
125469
  return undefined;
125416
125470
  }
125417
125471
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
125418
- var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125419
- if (normalizedTargetPath === undefined) {
125472
+ var normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
125473
+ if (normalizedTargetPaths === undefined) {
125474
+ return undefined;
125475
+ }
125476
+ var normalizedSourcePaths = getPathsRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125477
+ var relativePaths = ts.flatMap(normalizedSourcePaths, function (sourcePath) {
125478
+ return ts.map(normalizedTargetPaths, function (targetPath) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourcePath, targetPath, getCanonicalFileName)); });
125479
+ });
125480
+ var shortest = ts.min(relativePaths, ts.compareNumberOfDirectorySeparators);
125481
+ if (!shortest) {
125420
125482
  return undefined;
125421
125483
  }
125422
- var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
125423
- var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
125424
125484
  return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
125425
- ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
125426
- : ts.removeFileExtension(relativePath);
125485
+ ? removeExtensionAndIndexPostFix(shortest, ending, compilerOptions)
125486
+ : ts.removeFileExtension(shortest);
125427
125487
  }
125428
125488
  function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
125429
125489
  var path = _a.path, isRedirect = _a.isRedirect;
@@ -125560,8 +125620,8 @@ var ts;
125560
125620
  }
125561
125621
  }
125562
125622
  }
125563
- function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125564
- return ts.firstDefined(rootDirs, function (rootDir) {
125623
+ function getPathsRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
125624
+ return ts.mapDefined(rootDirs, function (rootDir) {
125565
125625
  var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
125566
125626
  return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
125567
125627
  });
@@ -146070,7 +146130,7 @@ var ts;
146070
146130
  return bestMatch;
146071
146131
  }
146072
146132
  function betterMatch(a, b) {
146073
- return ts.min(a, b, compareMatches);
146133
+ return ts.min([a, b], compareMatches);
146074
146134
  }
146075
146135
  function compareMatches(a, b) {
146076
146136
  return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */