@typescript-deploys/pr-build 4.6.0-pr-47183-2 → 4.6.0-pr-47400-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20211217";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220113";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -14650,7 +14650,8 @@ var ts;
14650
14650
  Float64Array: ["at"],
14651
14651
  BigInt64Array: ["at"],
14652
14652
  BigUint64Array: ["at"],
14653
- ObjectConstructor: ["hasOwn"]
14653
+ ObjectConstructor: ["hasOwn"],
14654
+ Error: ["cause"]
14654
14655
  }
14655
14656
  };
14656
14657
  }
@@ -19984,16 +19985,6 @@ var ts;
19984
19985
  (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real);
19985
19986
  }
19986
19987
  },
19987
- setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) {
19988
- this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real);
19989
- var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1];
19990
- if (commonResolved && commonOriginal) {
19991
- this.setSymlinkedDirectory(commonOriginal, {
19992
- real: commonResolved,
19993
- realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName),
19994
- });
19995
- }
19996
- },
19997
19988
  setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
19998
19989
  var _this = this;
19999
19990
  var _a;
@@ -20961,9 +20952,40 @@ var ts;
20961
20952
  }
20962
20953
  ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
20963
20954
  function escapeSnippetText(text) {
20964
- return text.replace(/\$/gm, "\\$");
20955
+ return text.replace(/\$/gm, function () { return "\\$"; });
20965
20956
  }
20966
20957
  ts.escapeSnippetText = escapeSnippetText;
20958
+ function isNumericLiteralName(name) {
20959
+ // The intent of numeric names is that
20960
+ // - they are names with text in a numeric form, and that
20961
+ // - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
20962
+ // acquired by applying the abstract 'ToNumber' operation on the name's text.
20963
+ //
20964
+ // The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name.
20965
+ // In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold.
20966
+ //
20967
+ // Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)'
20968
+ // according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'.
20969
+ // Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names
20970
+ // because their 'ToString' representation is not equal to their original text.
20971
+ // This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1.
20972
+ //
20973
+ // Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'.
20974
+ // The '+' prefix operator is equivalent here to applying the abstract ToNumber operation.
20975
+ // Applying the 'toString()' method on a number gives us the abstract ToString operation on a number.
20976
+ //
20977
+ // Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional.
20978
+ // This is desired behavior, because when indexing with them as numeric entities, you are indexing
20979
+ // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
20980
+ return (+name).toString() === name;
20981
+ }
20982
+ ts.isNumericLiteralName = isNumericLiteralName;
20983
+ function createPropertyNameNodeForIdentifierOrLiteral(name, target, singleQuote, stringNamed) {
20984
+ return ts.isIdentifierText(name, target) ? ts.factory.createIdentifier(name) :
20985
+ !stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
20986
+ ts.factory.createStringLiteral(name, !!singleQuote);
20987
+ }
20988
+ ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral;
20967
20989
  function isThisTypeParameter(type) {
20968
20990
  return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
20969
20991
  }
@@ -22436,7 +22458,7 @@ var ts;
22436
22458
  result.push(createModifier(144 /* ReadonlyKeyword */));
22437
22459
  if (flags & 256 /* Async */)
22438
22460
  result.push(createModifier(131 /* AsyncKeyword */));
22439
- return result;
22461
+ return result.length ? result : undefined;
22440
22462
  }
22441
22463
  //
22442
22464
  // Names
@@ -26393,32 +26415,36 @@ var ts;
26393
26415
  }
26394
26416
  function updateModifiers(node, modifiers) {
26395
26417
  var _a;
26418
+ var modifierArray;
26396
26419
  if (typeof modifiers === "number") {
26397
- modifiers = createModifiersFromModifierFlags(modifiers);
26398
- }
26399
- return ts.isParameter(node) ? updateParameterDeclaration(node, node.decorators, modifiers, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
26400
- ts.isPropertySignature(node) ? updatePropertySignature(node, modifiers, node.name, node.questionToken, node.type) :
26401
- ts.isPropertyDeclaration(node) ? updatePropertyDeclaration(node, node.decorators, modifiers, node.name, (_a = node.questionToken) !== null && _a !== void 0 ? _a : node.exclamationToken, node.type, node.initializer) :
26402
- ts.isMethodSignature(node) ? updateMethodSignature(node, modifiers, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) :
26403
- ts.isMethodDeclaration(node) ? updateMethodDeclaration(node, node.decorators, modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) :
26404
- ts.isConstructorDeclaration(node) ? updateConstructorDeclaration(node, node.decorators, modifiers, node.parameters, node.body) :
26405
- ts.isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, node.decorators, modifiers, node.name, node.parameters, node.type, node.body) :
26406
- ts.isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, node.decorators, modifiers, node.name, node.parameters, node.body) :
26407
- ts.isIndexSignatureDeclaration(node) ? updateIndexSignature(node, node.decorators, modifiers, node.parameters, node.type) :
26408
- ts.isFunctionExpression(node) ? updateFunctionExpression(node, modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26409
- ts.isArrowFunction(node) ? updateArrowFunction(node, modifiers, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) :
26410
- ts.isClassExpression(node) ? updateClassExpression(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
26411
- ts.isVariableStatement(node) ? updateVariableStatement(node, modifiers, node.declarationList) :
26412
- ts.isFunctionDeclaration(node) ? updateFunctionDeclaration(node, node.decorators, modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26413
- ts.isClassDeclaration(node) ? updateClassDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
26414
- ts.isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
26415
- ts.isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.type) :
26416
- ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifiers, node.name, node.members) :
26417
- ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifiers, node.name, node.body) :
26418
- ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.name, node.moduleReference) :
26419
- ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifiers, node.importClause, node.moduleSpecifier, node.assertClause) :
26420
- ts.isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifiers, node.expression) :
26421
- ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) :
26420
+ modifierArray = createModifiersFromModifierFlags(modifiers);
26421
+ }
26422
+ else {
26423
+ modifierArray = modifiers;
26424
+ }
26425
+ return ts.isParameter(node) ? updateParameterDeclaration(node, node.decorators, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
26426
+ ts.isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) :
26427
+ ts.isPropertyDeclaration(node) ? updatePropertyDeclaration(node, node.decorators, modifierArray, node.name, (_a = node.questionToken) !== null && _a !== void 0 ? _a : node.exclamationToken, node.type, node.initializer) :
26428
+ ts.isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) :
26429
+ ts.isMethodDeclaration(node) ? updateMethodDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) :
26430
+ ts.isConstructorDeclaration(node) ? updateConstructorDeclaration(node, node.decorators, modifierArray, node.parameters, node.body) :
26431
+ ts.isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.type, node.body) :
26432
+ ts.isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.body) :
26433
+ ts.isIndexSignatureDeclaration(node) ? updateIndexSignature(node, node.decorators, modifierArray, node.parameters, node.type) :
26434
+ ts.isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26435
+ ts.isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) :
26436
+ ts.isClassExpression(node) ? updateClassExpression(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
26437
+ ts.isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) :
26438
+ ts.isFunctionDeclaration(node) ? updateFunctionDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
26439
+ ts.isClassDeclaration(node) ? updateClassDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
26440
+ ts.isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
26441
+ ts.isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.type) :
26442
+ ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifierArray, node.name, node.members) :
26443
+ ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifierArray, node.name, node.body) :
26444
+ ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.name, node.moduleReference) :
26445
+ ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifierArray, node.importClause, node.moduleSpecifier, node.assertClause) :
26446
+ ts.isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifierArray, node.expression) :
26447
+ ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) :
26422
26448
  ts.Debug.assertNever(node);
26423
26449
  }
26424
26450
  function asNodeArray(array) {
@@ -41667,9 +41693,7 @@ var ts;
41667
41693
  }
41668
41694
  }
41669
41695
  var failedLookupLocations = [];
41670
- var features = ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
41671
- ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
41672
- NodeResolutionFeatures.None;
41696
+ var features = getDefaultNodeResolutionFeatures(options);
41673
41697
  var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
41674
41698
  var resolved = primaryLookup();
41675
41699
  var primary = true;
@@ -41754,6 +41778,34 @@ var ts;
41754
41778
  }
41755
41779
  }
41756
41780
  ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
41781
+ function getDefaultNodeResolutionFeatures(options) {
41782
+ return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
41783
+ ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
41784
+ NodeResolutionFeatures.None;
41785
+ }
41786
+ /**
41787
+ * @internal
41788
+ * Does not try `@types/${packageName}` - use a second pass if needed.
41789
+ */
41790
+ function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
41791
+ var moduleResolutionState = {
41792
+ compilerOptions: options,
41793
+ host: host,
41794
+ traceEnabled: isTraceEnabled(options, host),
41795
+ failedLookupLocations: [],
41796
+ packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
41797
+ conditions: ts.emptyArray,
41798
+ features: NodeResolutionFeatures.None,
41799
+ };
41800
+ return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
41801
+ if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
41802
+ var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
41803
+ var candidate = ts.combinePaths(nodeModulesFolder, packageName);
41804
+ return getPackageJsonInfo(candidate, /*onlyRecordFailures*/ false, moduleResolutionState);
41805
+ }
41806
+ });
41807
+ }
41808
+ ts.resolvePackageNameToPackageJson = resolvePackageNameToPackageJson;
41757
41809
  /**
41758
41810
  * Given a set of options, returns the set of type directive names
41759
41811
  * that should be included for this program automatically.
@@ -42327,11 +42379,6 @@ var ts;
42327
42379
  }
42328
42380
  ts.resolveJSModule = resolveJSModule;
42329
42381
  /* @internal */
42330
- function tryResolveJSModule(moduleName, initialDir, host) {
42331
- return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
42332
- }
42333
- ts.tryResolveJSModule = tryResolveJSModule;
42334
- /* @internal */
42335
42382
  var NodeResolutionFeatures;
42336
42383
  (function (NodeResolutionFeatures) {
42337
42384
  NodeResolutionFeatures[NodeResolutionFeatures["None"] = 0] = "None";
@@ -42639,6 +42686,97 @@ var ts;
42639
42686
  var versionPaths = packageInfo && packageInfo.versionPaths;
42640
42687
  return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
42641
42688
  }
42689
+ /* @internal */
42690
+ function getEntrypointsFromPackageJsonInfo(packageJsonInfo, options, host, cache, resolveJs) {
42691
+ if (!resolveJs && packageJsonInfo.resolvedEntrypoints !== undefined) {
42692
+ // Cached value excludes resolutions to JS files - those could be
42693
+ // cached separately, but they're used rarely.
42694
+ return packageJsonInfo.resolvedEntrypoints;
42695
+ }
42696
+ var entrypoints;
42697
+ var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
42698
+ var features = getDefaultNodeResolutionFeatures(options);
42699
+ var requireState = {
42700
+ compilerOptions: options,
42701
+ host: host,
42702
+ traceEnabled: isTraceEnabled(options, host),
42703
+ failedLookupLocations: [],
42704
+ packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42705
+ conditions: ["node", "require", "types"],
42706
+ features: features,
42707
+ };
42708
+ var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
42709
+ /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
42710
+ entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
42711
+ if (features & NodeResolutionFeatures.Exports && packageJsonInfo.packageJsonContent.exports) {
42712
+ for (var _i = 0, _a = [["node", "import", "types"], ["node", "require", "types"]]; _i < _a.length; _i++) {
42713
+ var conditions = _a[_i];
42714
+ var exportState = __assign(__assign({}, requireState), { failedLookupLocations: [], conditions: conditions });
42715
+ var exportResolutions = loadEntrypointsFromExportMap(packageJsonInfo, packageJsonInfo.packageJsonContent.exports, exportState, extensions);
42716
+ if (exportResolutions) {
42717
+ for (var _b = 0, exportResolutions_1 = exportResolutions; _b < exportResolutions_1.length; _b++) {
42718
+ var resolution = exportResolutions_1[_b];
42719
+ entrypoints = ts.appendIfUnique(entrypoints, resolution.path);
42720
+ }
42721
+ }
42722
+ }
42723
+ }
42724
+ return packageJsonInfo.resolvedEntrypoints = entrypoints || false;
42725
+ }
42726
+ ts.getEntrypointsFromPackageJsonInfo = getEntrypointsFromPackageJsonInfo;
42727
+ function loadEntrypointsFromExportMap(scope, exports, state, extensions) {
42728
+ var entrypoints;
42729
+ if (ts.isArray(exports)) {
42730
+ for (var _i = 0, exports_1 = exports; _i < exports_1.length; _i++) {
42731
+ var target = exports_1[_i];
42732
+ loadEntrypointsFromTargetExports(target);
42733
+ }
42734
+ }
42735
+ // eslint-disable-next-line no-null/no-null
42736
+ else if (typeof exports === "object" && exports !== null && allKeysStartWithDot(exports)) {
42737
+ for (var key in exports) {
42738
+ loadEntrypointsFromTargetExports(exports[key]);
42739
+ }
42740
+ }
42741
+ else {
42742
+ loadEntrypointsFromTargetExports(exports);
42743
+ }
42744
+ return entrypoints;
42745
+ function loadEntrypointsFromTargetExports(target) {
42746
+ var _a, _b;
42747
+ if (typeof target === "string" && ts.startsWith(target, "./") && target.indexOf("*") === -1) {
42748
+ var partsAfterFirst = ts.getPathComponents(target).slice(2);
42749
+ if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) {
42750
+ return false;
42751
+ }
42752
+ var resolvedTarget = ts.combinePaths(scope.packageDirectory, target);
42753
+ var finalPath = ts.getNormalizedAbsolutePath(resolvedTarget, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a));
42754
+ var result = loadJSOrExactTSFileName(extensions, finalPath, /*recordOnlyFailures*/ false, state);
42755
+ if (result) {
42756
+ entrypoints = ts.appendIfUnique(entrypoints, result, function (a, b) { return a.path === b.path; });
42757
+ return true;
42758
+ }
42759
+ }
42760
+ else if (Array.isArray(target)) {
42761
+ for (var _i = 0, target_1 = target; _i < target_1.length; _i++) {
42762
+ var t = target_1[_i];
42763
+ var success = loadEntrypointsFromTargetExports(t);
42764
+ if (success) {
42765
+ return true;
42766
+ }
42767
+ }
42768
+ }
42769
+ // eslint-disable-next-line no-null/no-null
42770
+ else if (typeof target === "object" && target !== null) {
42771
+ return ts.forEach(ts.getOwnKeys(target), function (key) {
42772
+ if (key === "default" || ts.contains(state.conditions, key) || isApplicableVersionedTypesKey(state.conditions, key)) {
42773
+ loadEntrypointsFromTargetExports(target[key]);
42774
+ return true;
42775
+ }
42776
+ });
42777
+ }
42778
+ }
42779
+ }
42642
42780
  /**
42643
42781
  * A function for locating the package.json scope for a given path
42644
42782
  */
@@ -42695,7 +42833,7 @@ var ts;
42695
42833
  trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
42696
42834
  }
42697
42835
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
42698
- var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
42836
+ var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
42699
42837
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
42700
42838
  return result;
42701
42839
  }
@@ -42992,8 +43130,8 @@ var ts;
42992
43130
  }
42993
43131
  return toSearchResult(/*value*/ undefined);
42994
43132
  }
42995
- for (var _d = 0, target_1 = target; _d < target_1.length; _d++) {
42996
- var elem = target_1[_d];
43133
+ for (var _d = 0, target_2 = target; _d < target_2.length; _d++) {
43134
+ var elem = target_2[_d];
42997
43135
  var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
42998
43136
  if (result) {
42999
43137
  return result;
@@ -47032,6 +47170,7 @@ var ts;
47032
47170
  var location = ts.getParseTreeNode(locationIn);
47033
47171
  return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
47034
47172
  },
47173
+ getTypeOfSymbol: getTypeOfSymbol,
47035
47174
  getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
47036
47175
  var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
47037
47176
  if (parameter === undefined)
@@ -50021,7 +50160,7 @@ var ts;
50021
50160
  if (!sigs || !sigs.length) {
50022
50161
  sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
50023
50162
  }
50024
- if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
50163
+ if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true)) {
50025
50164
  var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
50026
50165
  return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
50027
50166
  }
@@ -52225,8 +52364,8 @@ var ts;
52225
52364
  }
52226
52365
  else {
52227
52366
  if (parent && getExportsOfSymbol(parent)) {
52228
- var exports_1 = getExportsOfSymbol(parent);
52229
- ts.forEachEntry(exports_1, function (ex, name) {
52367
+ var exports_2 = getExportsOfSymbol(parent);
52368
+ ts.forEachEntry(exports_2, function (ex, name) {
52230
52369
  if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) {
52231
52370
  symbolName = ts.unescapeLeadingUnderscores(name);
52232
52371
  return true;
@@ -52387,7 +52526,7 @@ var ts;
52387
52526
  }
52388
52527
  var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
52389
52528
  var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed);
52390
- return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote);
52529
+ return ts.createPropertyNameNodeForIdentifierOrLiteral(rawName, ts.getEmitScriptTarget(compilerOptions), singleQuote, stringNamed);
52391
52530
  }
52392
52531
  // See getNameForSymbolFromNameType for a stringy equivalent
52393
52532
  function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
@@ -52395,24 +52534,19 @@ var ts;
52395
52534
  if (nameType) {
52396
52535
  if (nameType.flags & 384 /* StringOrNumberLiteral */) {
52397
52536
  var name = "" + nameType.value;
52398
- if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
52537
+ if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
52399
52538
  return ts.factory.createStringLiteral(name, !!singleQuote);
52400
52539
  }
52401
- if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
52540
+ if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
52402
52541
  return ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(+name));
52403
52542
  }
52404
- return createPropertyNameNodeForIdentifierOrLiteral(name);
52543
+ return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions));
52405
52544
  }
52406
52545
  if (nameType.flags & 8192 /* UniqueESSymbol */) {
52407
52546
  return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
52408
52547
  }
52409
52548
  }
52410
52549
  }
52411
- function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
52412
- return ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(name) :
52413
- !stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
52414
- ts.factory.createStringLiteral(name, !!singleQuote);
52415
- }
52416
52550
  function cloneNodeBuilderContext(context) {
52417
52551
  var initial = __assign({}, context);
52418
52552
  // Make type parameters created within this context not consume the name outside this context
@@ -53928,10 +54062,10 @@ var ts;
53928
54062
  if (nameType) {
53929
54063
  if (nameType.flags & 384 /* StringOrNumberLiteral */) {
53930
54064
  var name = "" + nameType.value;
53931
- if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
54065
+ if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
53932
54066
  return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\"";
53933
54067
  }
53934
- if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
54068
+ if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
53935
54069
  return "[" + name + "]";
53936
54070
  }
53937
54071
  return name;
@@ -57342,6 +57476,11 @@ var ts;
57342
57476
  return simplified !== type ? simplified : getConstraintOfType(type);
57343
57477
  }
57344
57478
  function getConstraintFromIndexedAccess(type) {
57479
+ if (isMappedTypeGenericIndexedAccess(type)) {
57480
+ // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
57481
+ // we substitute an instantiation of E where P is replaced with X.
57482
+ return substituteIndexedMappedType(type.objectType, type.indexType);
57483
+ }
57345
57484
  var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
57346
57485
  if (indexConstraint && indexConstraint !== type.indexType) {
57347
57486
  var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags);
@@ -57546,6 +57685,11 @@ var ts;
57546
57685
  return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
57547
57686
  }
57548
57687
  if (t.flags & 8388608 /* IndexedAccess */) {
57688
+ if (isMappedTypeGenericIndexedAccess(t)) {
57689
+ // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
57690
+ // we substitute an instantiation of E where P is replaced with X.
57691
+ return getBaseConstraint(substituteIndexedMappedType(t.objectType, t.indexType));
57692
+ }
57549
57693
  var baseObjectType = getBaseConstraint(t.objectType);
57550
57694
  var baseIndexType = getBaseConstraint(t.indexType);
57551
57695
  var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags);
@@ -57630,13 +57774,7 @@ var ts;
57630
57774
  * type itself.
57631
57775
  */
57632
57776
  function getApparentType(type) {
57633
- // We obtain the base constraint for all instantiable types, except indexed access types of the form
57634
- // { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
57635
- // instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
57636
- // lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
57637
- var t = !(type.flags & 465829888 /* Instantiable */) ? type :
57638
- isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
57639
- getBaseConstraintOfType(type) || unknownType;
57777
+ var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
57640
57778
  return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
57641
57779
  t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
57642
57780
  t.flags & 402653316 /* StringLike */ ? globalStringType :
@@ -57918,7 +58056,7 @@ var ts;
57918
58056
  return symbol_1;
57919
58057
  }
57920
58058
  }
57921
- return globalObjectType === undefined ? undefined : getPropertyOfObjectType(globalObjectType, name);
58059
+ return getPropertyOfObjectType(globalObjectType, name);
57922
58060
  }
57923
58061
  if (type.flags & 3145728 /* UnionOrIntersection */) {
57924
58062
  return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
@@ -57974,7 +58112,7 @@ var ts;
57974
58112
  // signature applies to types assignable to 'number' and numeric string literal types.
57975
58113
  return isTypeAssignableTo(source, target) ||
57976
58114
  target === stringType && isTypeAssignableTo(source, numberType) ||
57977
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && isNumericLiteralName(source.value);
58115
+ target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
57978
58116
  }
57979
58117
  function getIndexInfosOfStructuredType(type) {
57980
58118
  if (type.flags & 3670016 /* StructuredType */) {
@@ -60540,7 +60678,7 @@ var ts;
60540
60678
  getFlowTypeOfReference(accessExpression, propType) :
60541
60679
  propType;
60542
60680
  }
60543
- if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
60681
+ if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
60544
60682
  if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
60545
60683
  var indexNode = getIndexNodeForAccessExpression(accessNode);
60546
60684
  if (isTupleType(objectType)) {
@@ -60825,7 +60963,7 @@ var ts;
60825
60963
  return everyType(indexType, function (t) {
60826
60964
  if (t.flags & 384 /* StringOrNumberLiteral */) {
60827
60965
  var propName = getPropertyNameFromType(t);
60828
- if (isNumericLiteralName(propName)) {
60966
+ if (ts.isNumericLiteralName(propName)) {
60829
60967
  var index = +propName;
60830
60968
  return index >= 0 && index < limit;
60831
60969
  }
@@ -64300,6 +64438,17 @@ var ts;
64300
64438
  resetErrorInfo(saveErrorInfo);
64301
64439
  return result;
64302
64440
  }
64441
+ if (isMappedTypeGenericIndexedAccess(source)) {
64442
+ // For an indexed access type { [P in K]: E}[X], above we have already explored an instantiation of E with X
64443
+ // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X.
64444
+ var indexConstraint = getConstraintOfType(source.indexType);
64445
+ if (indexConstraint) {
64446
+ if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
64447
+ resetErrorInfo(saveErrorInfo);
64448
+ return result;
64449
+ }
64450
+ }
64451
+ }
64303
64452
  }
64304
64453
  }
64305
64454
  else if (source.flags & 4194304 /* Index */) {
@@ -64367,7 +64516,7 @@ var ts;
64367
64516
  else {
64368
64517
  // conditionals aren't related to one another via distributive constraint as it is much too inaccurate and allows way
64369
64518
  // more assignments than are desirable (since it maps the source check type to its constraint, it loses information)
64370
- var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
64519
+ var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
64371
64520
  if (distributiveConstraint) {
64372
64521
  if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
64373
64522
  resetErrorInfo(saveErrorInfo);
@@ -64913,7 +65062,7 @@ var ts;
64913
65062
  for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
64914
65063
  var targetProp = _c[_b];
64915
65064
  var name = targetProp.escapedName;
64916
- if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
65065
+ if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) {
64917
65066
  var sourceProp = getPropertyOfType(source, name);
64918
65067
  if (sourceProp && sourceProp !== targetProp) {
64919
65068
  var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
@@ -64986,7 +65135,8 @@ var ts;
64986
65135
  var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
64987
65136
  var sourceObjectFlags = ts.getObjectFlags(source);
64988
65137
  var targetObjectFlags = ts.getObjectFlags(target);
64989
- if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol) {
65138
+ if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol ||
65139
+ sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) {
64990
65140
  // We have instantiations of the same anonymous type (which typically will be the type of a
64991
65141
  // method). Simply do a pairwise comparison of the signatures in the two signature lists instead
64992
65142
  // of the much more expensive N * M comparison matrix we explore below. We erase type parameters
@@ -66021,9 +66171,12 @@ var ts;
66021
66171
  * with no call or construct signatures.
66022
66172
  */
66023
66173
  function isObjectTypeWithInferableIndex(type) {
66024
- return type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) :
66025
- !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 &&
66026
- !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
66174
+ return type.flags & 2097152 /* Intersection */
66175
+ ? ts.every(type.types, isObjectTypeWithInferableIndex)
66176
+ : !!(type.symbol
66177
+ && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
66178
+ && !(type.symbol.flags & 32 /* Class */)
66179
+ && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
66027
66180
  }
66028
66181
  function createSymbolWithType(source, type) {
66029
66182
  var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
@@ -67631,7 +67784,8 @@ var ts;
67631
67784
  return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
67632
67785
  access.kind === 206 /* ElementAccessExpression */ && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
67633
67786
  access.kind === 202 /* BindingElement */ && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) :
67634
- undefined;
67787
+ access.kind === 163 /* Parameter */ ? ("" + access.parent.parameters.indexOf(access)) :
67788
+ undefined;
67635
67789
  }
67636
67790
  function containsMatchingReference(source, target) {
67637
67791
  while (ts.isAccessExpression(source)) {
@@ -68971,13 +69125,14 @@ var ts;
68971
69125
  return result;
68972
69126
  }
68973
69127
  function getCandidateDiscriminantPropertyAccess(expr) {
68974
- if (ts.isBindingPattern(reference)) {
68975
- // When the reference is a binding pattern, we are narrowing a pesudo-reference in getNarrowedTypeOfSymbol.
68976
- // An identifier for a destructuring variable declared in the same binding pattern is a candidate.
69128
+ if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference)) {
69129
+ // When the reference is a binding pattern or function or arrow expression, we are narrowing a pesudo-reference in
69130
+ // getNarrowedTypeOfSymbol. An identifier for a destructuring variable declared in the same binding pattern or
69131
+ // parameter declared in the same parameter list is a candidate.
68977
69132
  if (ts.isIdentifier(expr)) {
68978
69133
  var symbol = getResolvedSymbol(expr);
68979
69134
  var declaration = symbol.valueDeclaration;
68980
- if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && reference === declaration.parent) {
69135
+ if (declaration && (ts.isBindingElement(declaration) || ts.isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
68981
69136
  return declaration;
68982
69137
  }
68983
69138
  }
@@ -69779,42 +69934,78 @@ var ts;
69779
69934
  }
69780
69935
  }
69781
69936
  function getNarrowedTypeOfSymbol(symbol, location) {
69782
- // If we have a non-rest binding element with no initializer declared as a const variable or a const-like
69783
- // parameter (a parameter for which there are no assignments in the function body), and if the parent type
69784
- // for the destructuring is a union type, one or more of the binding elements may represent discriminant
69785
- // properties, and we want the effects of conditional checks on such discriminants to affect the types of
69786
- // other binding elements from the same destructuring. Consider:
69787
- //
69788
- // type Action =
69789
- // | { kind: 'A', payload: number }
69790
- // | { kind: 'B', payload: string };
69791
- //
69792
- // function f1({ kind, payload }: Action) {
69793
- // if (kind === 'A') {
69794
- // payload.toFixed();
69795
- // }
69796
- // if (kind === 'B') {
69797
- // payload.toUpperCase();
69798
- // }
69799
- // }
69800
- //
69801
- // Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
69802
- // the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
69803
- // as if it occurred in the specified location. We then recompute the narrowed binding element type by
69804
- // destructuring from the narrowed parent type.
69805
69937
  var declaration = symbol.valueDeclaration;
69806
- if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
69807
- var parent = declaration.parent.parent;
69808
- if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
69809
- var links = getNodeLinks(location);
69810
- if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
69811
- links.flags |= 268435456 /* InCheckIdentifier */;
69812
- var parentType = getTypeForBindingElementParent(parent);
69813
- links.flags &= ~268435456 /* InCheckIdentifier */;
69814
- if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
69815
- var pattern = declaration.parent;
69816
- var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
69817
- return getBindingElementTypeFromParentType(declaration, narrowedType);
69938
+ if (declaration) {
69939
+ // If we have a non-rest binding element with no initializer declared as a const variable or a const-like
69940
+ // parameter (a parameter for which there are no assignments in the function body), and if the parent type
69941
+ // for the destructuring is a union type, one or more of the binding elements may represent discriminant
69942
+ // properties, and we want the effects of conditional checks on such discriminants to affect the types of
69943
+ // other binding elements from the same destructuring. Consider:
69944
+ //
69945
+ // type Action =
69946
+ // | { kind: 'A', payload: number }
69947
+ // | { kind: 'B', payload: string };
69948
+ //
69949
+ // function f({ kind, payload }: Action) {
69950
+ // if (kind === 'A') {
69951
+ // payload.toFixed();
69952
+ // }
69953
+ // if (kind === 'B') {
69954
+ // payload.toUpperCase();
69955
+ // }
69956
+ // }
69957
+ //
69958
+ // Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
69959
+ // the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
69960
+ // as if it occurred in the specified location. We then recompute the narrowed binding element type by
69961
+ // destructuring from the narrowed parent type.
69962
+ if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
69963
+ var parent = declaration.parent.parent;
69964
+ if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
69965
+ var links = getNodeLinks(location);
69966
+ if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
69967
+ links.flags |= 268435456 /* InCheckIdentifier */;
69968
+ var parentType = getTypeForBindingElementParent(parent);
69969
+ links.flags &= ~268435456 /* InCheckIdentifier */;
69970
+ if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
69971
+ var pattern = declaration.parent;
69972
+ var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
69973
+ return getBindingElementTypeFromParentType(declaration, narrowedType);
69974
+ }
69975
+ }
69976
+ }
69977
+ }
69978
+ // If we have a const-like parameter with no type annotation or initializer, and if the parameter is contextually
69979
+ // typed by a signature with a single rest parameter of a union of tuple types, one or more of the parameters may
69980
+ // represent discriminant tuple elements, and we want the effects of conditional checks on such discriminants to
69981
+ // affect the types of other parameters in the same parameter list. Consider:
69982
+ //
69983
+ // type Action = [kind: 'A', payload: number] | [kind: 'B', payload: string];
69984
+ //
69985
+ // const f: (...args: Action) => void = (kind, payload) => {
69986
+ // if (kind === 'A') {
69987
+ // payload.toFixed();
69988
+ // }
69989
+ // if (kind === 'B') {
69990
+ // payload.toUpperCase();
69991
+ // }
69992
+ // }
69993
+ //
69994
+ // Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
69995
+ // the arrow function AST node for '(kind, payload) => ...' as a pseudo-reference and narrow this reference as
69996
+ // if it occurred in the specified location. We then recompute the narrowed parameter type by indexing into the
69997
+ // narrowed tuple type.
69998
+ if (ts.isParameter(declaration) && !declaration.type && !declaration.initializer && !declaration.dotDotDotToken) {
69999
+ var func = declaration.parent;
70000
+ if (func.parameters.length >= 2 && isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
70001
+ var contextualSignature = getContextualSignature(func);
70002
+ if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) {
70003
+ var restType = getTypeOfSymbol(contextualSignature.parameters[0]);
70004
+ if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) {
70005
+ var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode);
70006
+ var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0);
70007
+ return getIndexedAccessType(narrowedType, getNumberLiteralType(index));
70008
+ }
69818
70009
  }
69819
70010
  }
69820
70011
  }
@@ -70955,7 +71146,7 @@ var ts;
70955
71146
  }
70956
71147
  if (isTupleType(t)) {
70957
71148
  var restType = getRestTypeOfTupleType(t);
70958
- if (restType && isNumericLiteralName(name) && +name >= 0) {
71149
+ if (restType && ts.isNumericLiteralName(name) && +name >= 0) {
70959
71150
  return restType;
70960
71151
  }
70961
71152
  }
@@ -71596,10 +71787,10 @@ var ts;
71596
71787
  case 161 /* ComputedPropertyName */:
71597
71788
  return isNumericComputedName(name);
71598
71789
  case 79 /* Identifier */:
71599
- return isNumericLiteralName(name.escapedText);
71790
+ return ts.isNumericLiteralName(name.escapedText);
71600
71791
  case 8 /* NumericLiteral */:
71601
71792
  case 10 /* StringLiteral */:
71602
- return isNumericLiteralName(name.text);
71793
+ return ts.isNumericLiteralName(name.text);
71603
71794
  default:
71604
71795
  return false;
71605
71796
  }
@@ -71609,30 +71800,6 @@ var ts;
71609
71800
  // but this behavior is consistent with checkIndexedAccess
71610
71801
  return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */);
71611
71802
  }
71612
- function isNumericLiteralName(name) {
71613
- // The intent of numeric names is that
71614
- // - they are names with text in a numeric form, and that
71615
- // - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
71616
- // acquired by applying the abstract 'ToNumber' operation on the name's text.
71617
- //
71618
- // The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name.
71619
- // In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold.
71620
- //
71621
- // Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)'
71622
- // according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'.
71623
- // Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names
71624
- // because their 'ToString' representation is not equal to their original text.
71625
- // This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1.
71626
- //
71627
- // Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'.
71628
- // The '+' prefix operator is equivalent here to applying the abstract ToNumber operation.
71629
- // Applying the 'toString()' method on a number gives us the abstract ToString operation on a number.
71630
- //
71631
- // Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional.
71632
- // This is desired behavior, because when indexing with them as numeric entities, you are indexing
71633
- // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
71634
- return (+name).toString() === name;
71635
- }
71636
71803
  function checkComputedPropertyName(node) {
71637
71804
  var links = getNodeLinks(node.expression);
71638
71805
  if (!links.resolvedType) {
@@ -71668,7 +71835,7 @@ var ts;
71668
71835
  function isSymbolWithNumericName(symbol) {
71669
71836
  var _a;
71670
71837
  var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
71671
- return isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
71838
+ return ts.isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
71672
71839
  }
71673
71840
  function isSymbolWithSymbolName(symbol) {
71674
71841
  var _a;
@@ -72891,6 +73058,9 @@ var ts;
72891
73058
  if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
72892
73059
  error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
72893
73060
  }
73061
+ if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
73062
+ addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
73063
+ }
72894
73064
  }
72895
73065
  else {
72896
73066
  if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) {
@@ -82606,7 +82776,7 @@ var ts;
82606
82776
  }
82607
82777
  else {
82608
82778
  var text = ts.getTextOfPropertyName(member.name);
82609
- if (isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
82779
+ if (ts.isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
82610
82780
  error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
82611
82781
  }
82612
82782
  }
@@ -83400,9 +83570,9 @@ var ts;
83400
83570
  }
83401
83571
  }
83402
83572
  // Checks for export * conflicts
83403
- var exports_2 = getExportsOfModule(moduleSymbol);
83404
- if (exports_2) {
83405
- exports_2.forEach(function (_a, id) {
83573
+ var exports_3 = getExportsOfModule(moduleSymbol);
83574
+ if (exports_3) {
83575
+ exports_3.forEach(function (_a, id) {
83406
83576
  var declarations = _a.declarations, flags = _a.flags;
83407
83577
  if (id === "__export") {
83408
83578
  return;
@@ -92958,6 +93128,11 @@ var ts;
92958
93128
  ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
92959
93129
  ts.setCommentRange(statement, property);
92960
93130
  ts.setOriginalNode(statement, property);
93131
+ // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93132
+ // `statement` and `expression` have a copy of the synthesized comments.
93133
+ // Drop the comments from expression to avoid printing them twice.
93134
+ ts.setSyntheticLeadingComments(expression, undefined);
93135
+ ts.setSyntheticTrailingComments(expression, undefined);
92961
93136
  statements.push(statement);
92962
93137
  }
92963
93138
  }
@@ -109212,7 +109387,7 @@ var ts;
109212
109387
  emitPlaceholder(hint, node, snippet);
109213
109388
  break;
109214
109389
  case 0 /* TabStop */:
109215
- emitTabStop(snippet);
109390
+ emitTabStop(hint, node, snippet);
109216
109391
  break;
109217
109392
  }
109218
109393
  }
@@ -109222,7 +109397,10 @@ var ts;
109222
109397
  nonEscapingWrite("}"); // `}`
109223
109398
  // `${2:...}`
109224
109399
  }
109225
- function emitTabStop(snippet) {
109400
+ function emitTabStop(hint, node, snippet) {
109401
+ // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text.
109402
+ ts.Debug.assert(node.kind === 235 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + ".");
109403
+ ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement.");
109226
109404
  nonEscapingWrite("$" + snippet.order);
109227
109405
  }
109228
109406
  //
@@ -119295,28 +119473,37 @@ var ts;
119295
119473
  useCaseSensitiveFileNames: (_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host),
119296
119474
  };
119297
119475
  }
119298
- function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
119299
- var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
119476
+ // `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
119477
+ // Because when this is called by the file renamer, `importingSourceFile` is the file being renamed,
119478
+ // while `importingSourceFileName` its *new* name. We need a source file just to get its
119479
+ // `impliedNodeFormat` and to detect certain preferences from existing import module specifiers.
119480
+ function updateModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, oldImportSpecifier) {
119481
+ var res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
119300
119482
  if (res === oldImportSpecifier)
119301
119483
  return undefined;
119302
119484
  return res;
119303
119485
  }
119304
119486
  moduleSpecifiers_1.updateModuleSpecifier = updateModuleSpecifier;
119305
- // Note: importingSourceFile is just for usesJsExtensionOnImports
119487
+ // `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
119488
+ // Because when this is called by the declaration emitter, `importingSourceFile` is the implementation
119489
+ // file, but `importingSourceFileName` and `toFileName` refer to declaration files (the former to the
119490
+ // one currently being produced; the latter to the one being imported). We need an implementation file
119491
+ // just to get its `impliedNodeFormat` and to detect certain preferences from existing import module
119492
+ // specifiers.
119306
119493
  function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) {
119307
- return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
119494
+ return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
119308
119495
  }
119309
119496
  moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier;
119310
- function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, preferences) {
119311
- var info = getInfo(importingSourceFileName, host);
119312
- var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host, preferences);
119313
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions, /*packageNameOnly*/ true); });
119497
+ function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeModulesFileName, host, preferences) {
119498
+ var info = getInfo(importingSourceFile.path, host);
119499
+ var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences);
119500
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true); });
119314
119501
  }
119315
119502
  moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
119316
- function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences, userPreferences) {
119503
+ function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences) {
119317
119504
  var info = getInfo(importingSourceFileName, host);
119318
119505
  var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences);
119319
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) ||
119506
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions); }) ||
119320
119507
  getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
119321
119508
  }
119322
119509
  function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences) {
@@ -119383,7 +119570,7 @@ var ts;
119383
119570
  var relativeSpecifiers;
119384
119571
  for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
119385
119572
  var modulePath = modulePaths_1[_i];
119386
- var specifier = tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions);
119573
+ var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions);
119387
119574
  nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
119388
119575
  if (specifier && modulePath.isRedirect) {
119389
119576
  // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
@@ -119775,7 +119962,7 @@ var ts;
119775
119962
  ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
119776
119963
  : ts.removeFileExtension(relativePath);
119777
119964
  }
119778
- function tryGetModuleNameAsNodeModule(_a, _b, host, options, packageNameOnly) {
119965
+ function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly) {
119779
119966
  var path = _a.path, isRedirect = _a.isRedirect;
119780
119967
  var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
119781
119968
  if (!host.fileExists || !host.readFile) {
@@ -119838,11 +120025,19 @@ var ts;
119838
120025
  var moduleFileToTry = path;
119839
120026
  if (host.fileExists(packageJsonPath)) {
119840
120027
  var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
119841
- // TODO: Inject `require` or `import` condition based on the intended import mode
119842
120028
  if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
119843
- var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
120029
+ // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
120030
+ // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
120031
+ // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
120032
+ // with, so for now we just stick with the mode of the file.
120033
+ var conditions = ["node", importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
120034
+ var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
120035
+ ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
120036
+ : undefined;
119844
120037
  if (fromExports) {
119845
- var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
120038
+ var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry)
120039
+ ? fromExports
120040
+ : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119846
120041
  return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119847
120042
  }
119848
120043
  if (packageJsonContent.exports) {
@@ -119948,8 +120143,8 @@ var ts;
119948
120143
  }
119949
120144
  function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
119950
120145
  return ts.firstDefined(rootDirs, function (rootDir) {
119951
- var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName); // TODO: GH#18217
119952
- return isPathRelativeToParent(relativePath) ? undefined : relativePath;
120146
+ var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
120147
+ return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
119953
120148
  });
119954
120149
  }
119955
120150
  function removeExtensionAndIndexPostFix(fileName, ending, options) {
@@ -120068,7 +120263,7 @@ var ts;
120068
120263
  }
120069
120264
  ts.getLocaleTimeString = getLocaleTimeString;
120070
120265
  /**
120071
- * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic
120266
+ * Create a function that reports watch status by writing to the system and handles the formatting of the diagnostic
120072
120267
  */
120073
120268
  function createWatchStatusReporter(system, pretty) {
120074
120269
  return pretty ?
@@ -120129,7 +120324,7 @@ var ts;
120129
120324
  ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
120130
120325
  }
120131
120326
  ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
120132
- function getErrorSummaryText(errorCount, filesInError, newLine) {
120327
+ function getErrorSummaryText(errorCount, filesInError, newLine, host) {
120133
120328
  if (errorCount === 0)
120134
120329
  return "";
120135
120330
  var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
@@ -120144,10 +120339,10 @@ var ts;
120144
120339
  distinctFileNamesWithLines.length === 1 ?
120145
120340
  ts.Diagnostics.Found_0_errors_in_1_file :
120146
120341
  ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
120147
- return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles) : "");
120342
+ return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "");
120148
120343
  }
120149
120344
  ts.getErrorSummaryText = getErrorSummaryText;
120150
- function createTabularErrorsDisplay(filesInError) {
120345
+ function createTabularErrorsDisplay(filesInError, host) {
120151
120346
  var distinctFiles = filesInError.filter(function (value, index, self) { return index === self.findIndex(function (file) { return (file === null || file === void 0 ? void 0 : file.fileName) === (value === null || value === void 0 ? void 0 : value.fileName); }); });
120152
120347
  if (distinctFiles.length === 0)
120153
120348
  return "";
@@ -120166,7 +120361,8 @@ var ts;
120166
120361
  var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
120167
120362
  " ".repeat(leftPaddingGoal - errorCountDigitsLength)
120168
120363
  : "";
120169
- tabularData += "" + leftPadding + errorCount + " " + file.fileName + ":" + file.line + "\n";
120364
+ var relativePath = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), file.fileName, /* ignoreCase */ false);
120365
+ tabularData += "" + leftPadding + errorCount + " " + relativePath + ":" + file.line + "\n";
120170
120366
  });
120171
120367
  return tabularData;
120172
120368
  }
@@ -120584,7 +120780,7 @@ var ts;
120584
120780
  var system = input.system || ts.sys;
120585
120781
  var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
120586
120782
  var builderProgram = ts.createIncrementalProgram(input);
120587
- var exitStatus = emitFilesAndReportErrorsAndGetExitStatus(builderProgram, input.reportDiagnostic || createDiagnosticReporter(system), function (s) { return host.trace && host.trace(s); }, input.reportErrorSummary || input.options.pretty ? function (errorCount, filesInError) { return system.write(getErrorSummaryText(errorCount, filesInError, system.newLine)); } : undefined);
120783
+ var exitStatus = emitFilesAndReportErrorsAndGetExitStatus(builderProgram, input.reportDiagnostic || createDiagnosticReporter(system), function (s) { return host.trace && host.trace(s); }, input.reportErrorSummary || input.options.pretty ? function (errorCount, filesInError) { return system.write(getErrorSummaryText(errorCount, filesInError, system.newLine, host)); } : undefined);
120588
120784
  if (input.afterProgramEmitAndDiagnostics)
120589
120785
  input.afterProgramEmitAndDiagnostics(builderProgram);
120590
120786
  return exitStatus;
@@ -123058,14 +123254,8 @@ var ts;
123058
123254
  var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
123059
123255
  possibleSearchDirs.add(projectRootPath);
123060
123256
  possibleSearchDirs.forEach(function (searchDir) {
123061
- var packageJsonPath = ts.combinePaths(searchDir, "package.json");
123062
- getTypingNamesFromJson(packageJsonPath, filesToWatch);
123063
- var bowerJsonPath = ts.combinePaths(searchDir, "bower.json");
123064
- getTypingNamesFromJson(bowerJsonPath, filesToWatch);
123065
- var bowerComponentsPath = ts.combinePaths(searchDir, "bower_components");
123066
- getTypingNamesFromPackagesFolder(bowerComponentsPath, filesToWatch);
123067
- var nodeModulesPath = ts.combinePaths(searchDir, "node_modules");
123068
- getTypingNamesFromPackagesFolder(nodeModulesPath, filesToWatch);
123257
+ getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
123258
+ getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
123069
123259
  });
123070
123260
  if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
123071
123261
  getTypingNamesFromSourceFileNames(fileNames);
@@ -123114,16 +123304,100 @@ var ts;
123114
123304
  ts.forEach(typingNames, addInferredTyping);
123115
123305
  }
123116
123306
  /**
123117
- * Get the typing info from common package manager json files like package.json or bower.json
123307
+ * Adds inferred typings from manifest/module pairs (think package.json + node_modules)
123308
+ *
123309
+ * @param projectRootPath is the path to the directory where to look for package.json, bower.json and other typing information
123310
+ * @param manifestName is the name of the manifest (package.json or bower.json)
123311
+ * @param modulesDirName is the directory name for modules (node_modules or bower_components). Should be lowercase!
123312
+ * @param filesToWatch are the files to watch for changes. We will push things into this array.
123118
123313
  */
123119
- function getTypingNamesFromJson(jsonPath, filesToWatch) {
123120
- if (!host.fileExists(jsonPath)) {
123314
+ function getTypingNames(projectRootPath, manifestName, modulesDirName, filesToWatch) {
123315
+ // First, we check the manifests themselves. They're not
123316
+ // _required_, but they allow us to do some filtering when dealing
123317
+ // with big flat dep directories.
123318
+ var manifestPath = ts.combinePaths(projectRootPath, manifestName);
123319
+ var manifest;
123320
+ var manifestTypingNames;
123321
+ if (host.fileExists(manifestPath)) {
123322
+ filesToWatch.push(manifestPath);
123323
+ manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config;
123324
+ manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys);
123325
+ addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies");
123326
+ }
123327
+ // Now we scan the directories for typing information in
123328
+ // already-installed dependencies (if present). Note that this
123329
+ // step happens regardless of whether a manifest was present,
123330
+ // which is certainly a valid configuration, if an unusual one.
123331
+ var packagesFolderPath = ts.combinePaths(projectRootPath, modulesDirName);
123332
+ filesToWatch.push(packagesFolderPath);
123333
+ if (!host.directoryExists(packagesFolderPath)) {
123121
123334
  return;
123122
123335
  }
123123
- filesToWatch.push(jsonPath);
123124
- var jsonConfig = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }).config;
123125
- var jsonTypingNames = ts.flatMap([jsonConfig.dependencies, jsonConfig.devDependencies, jsonConfig.optionalDependencies, jsonConfig.peerDependencies], ts.getOwnKeys);
123126
- addInferredTypings(jsonTypingNames, "Typing names in '" + jsonPath + "' dependencies");
123336
+ // There's two cases we have to take into account here:
123337
+ // 1. If manifest is undefined, then we're not using a manifest.
123338
+ // That means that we should scan _all_ dependencies at the top
123339
+ // level of the modulesDir.
123340
+ // 2. If manifest is defined, then we can do some special
123341
+ // filtering to reduce the amount of scanning we need to do.
123342
+ //
123343
+ // Previous versions of this algorithm checked for a `_requiredBy`
123344
+ // field in the package.json, but that field is only present in
123345
+ // `npm@>=3 <7`.
123346
+ // Package names that do **not** provide their own typings, so
123347
+ // we'll look them up.
123348
+ var packageNames = [];
123349
+ var dependencyManifestNames = manifestTypingNames
123350
+ // This is #1 described above.
123351
+ ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); })
123352
+ // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json`
123353
+ : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3)
123354
+ .filter(function (manifestPath) {
123355
+ if (ts.getBaseFileName(manifestPath) !== manifestName) {
123356
+ return false;
123357
+ }
123358
+ // It's ok to treat
123359
+ // `node_modules/@foo/bar/package.json` as a manifest,
123360
+ // but not `node_modules/jquery/nested/package.json`.
123361
+ // We only assume depth 3 is ok for formally scoped
123362
+ // packages. So that needs this dance here.
123363
+ var pathComponents = ts.getPathComponents(ts.normalizePath(manifestPath));
123364
+ var isScoped = pathComponents[pathComponents.length - 3][0] === "@";
123365
+ return isScoped && pathComponents[pathComponents.length - 4].toLowerCase() === modulesDirName || // `node_modules/@foo/bar`
123366
+ !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo`
123367
+ });
123368
+ if (log)
123369
+ log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames));
123370
+ // Once we have the names of things to look up, we iterate over
123371
+ // and either collect their included typings, or add them to the
123372
+ // list of typings we need to look up separately.
123373
+ for (var _i = 0, dependencyManifestNames_1 = dependencyManifestNames; _i < dependencyManifestNames_1.length; _i++) {
123374
+ var manifestPath_1 = dependencyManifestNames_1[_i];
123375
+ var normalizedFileName = ts.normalizePath(manifestPath_1);
123376
+ var result_1 = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
123377
+ var manifest_1 = result_1.config;
123378
+ // If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
123379
+ // to download d.ts files from DefinitelyTyped
123380
+ if (!manifest_1.name) {
123381
+ continue;
123382
+ }
123383
+ var ownTypes = manifest_1.types || manifest_1.typings;
123384
+ if (ownTypes) {
123385
+ var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName));
123386
+ if (host.fileExists(absolutePath)) {
123387
+ if (log)
123388
+ log(" Package '" + manifest_1.name + "' provides its own types.");
123389
+ inferredTypings.set(manifest_1.name, absolutePath);
123390
+ }
123391
+ else {
123392
+ if (log)
123393
+ log(" Package '" + manifest_1.name + "' provides its own types but they are missing.");
123394
+ }
123395
+ }
123396
+ else {
123397
+ packageNames.push(manifest_1.name);
123398
+ }
123399
+ }
123400
+ addInferredTypings(packageNames, " Found package names");
123127
123401
  }
123128
123402
  /**
123129
123403
  * Infer typing names from given file names. For example, the file name "jquery-min.2.3.4.js"
@@ -123149,55 +123423,6 @@ var ts;
123149
123423
  addInferredTyping("react");
123150
123424
  }
123151
123425
  }
123152
- /**
123153
- * Infer typing names from packages folder (ex: node_module, bower_components)
123154
- * @param packagesFolderPath is the path to the packages folder
123155
- */
123156
- function getTypingNamesFromPackagesFolder(packagesFolderPath, filesToWatch) {
123157
- filesToWatch.push(packagesFolderPath);
123158
- // Todo: add support for ModuleResolutionHost too
123159
- if (!host.directoryExists(packagesFolderPath)) {
123160
- return;
123161
- }
123162
- // depth of 2, so we access `node_modules/foo` but not `node_modules/foo/bar`
123163
- var fileNames = host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2);
123164
- if (log)
123165
- log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(fileNames));
123166
- var packageNames = [];
123167
- for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
123168
- var fileName = fileNames_1[_i];
123169
- var normalizedFileName = ts.normalizePath(fileName);
123170
- var baseFileName = ts.getBaseFileName(normalizedFileName);
123171
- if (baseFileName !== "package.json" && baseFileName !== "bower.json") {
123172
- continue;
123173
- }
123174
- var result_1 = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
123175
- var packageJson = result_1.config;
123176
- // npm 3's package.json contains a "_requiredBy" field
123177
- // we should include all the top level module names for npm 2, and only module names whose
123178
- // "_requiredBy" field starts with "#" or equals "/" for npm 3.
123179
- if (baseFileName === "package.json" && packageJson._requiredBy &&
123180
- ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) {
123181
- continue;
123182
- }
123183
- // If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
123184
- // to download d.ts files from DefinitelyTyped
123185
- if (!packageJson.name) {
123186
- continue;
123187
- }
123188
- var ownTypes = packageJson.types || packageJson.typings;
123189
- if (ownTypes) {
123190
- var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName));
123191
- if (log)
123192
- log(" Package '" + packageJson.name + "' provides its own types.");
123193
- inferredTypings.set(packageJson.name, absolutePath);
123194
- }
123195
- else {
123196
- packageNames.push(packageJson.name);
123197
- }
123198
- }
123199
- addInferredTypings(packageNames, " Found package names");
123200
- }
123201
123426
  }
123202
123427
  JsTyping.discoverTypings = discoverTypings;
123203
123428
  var NameValidationResult;
@@ -126548,7 +126773,7 @@ var ts;
126548
126773
  if (!ts.stringContains(importedFileName, "node_modules")) {
126549
126774
  return undefined;
126550
126775
  }
126551
- var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, preferences);
126776
+ var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile, importedFileName, moduleSpecifierResolutionHost, preferences);
126552
126777
  if (!specifier) {
126553
126778
  return undefined;
126554
126779
  }
@@ -126748,6 +126973,16 @@ var ts;
126748
126973
  : ts.getLocaleSpecificMessage(diag);
126749
126974
  }
126750
126975
  ts.diagnosticToString = diagnosticToString;
126976
+ /**
126977
+ * Get format code settings for a code writing context (e.g. when formatting text changes or completions code).
126978
+ */
126979
+ function getFormatCodeSettingsForWriting(_a, sourceFile) {
126980
+ var options = _a.options;
126981
+ var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore;
126982
+ var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !probablyUsesSemicolons(sourceFile);
126983
+ return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
126984
+ }
126985
+ ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
126751
126986
  // #endregion
126752
126987
  })(ts || (ts = {}));
126753
126988
  /*@internal*/
@@ -128371,7 +128606,8 @@ var ts;
128371
128606
  return convertPathCompletions(completion.paths);
128372
128607
  case 1 /* Properties */: {
128373
128608
  var entries = ts.createSortedArray();
128374
- Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary
128609
+ Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options,
128610
+ /*formatContext*/ undefined); // Target will not be used, so arbitrary
128375
128611
  return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
128376
128612
  }
128377
128613
  case 2 /* Types */: {
@@ -129192,7 +129428,7 @@ var ts;
129192
129428
  return result;
129193
129429
  }
129194
129430
  }
129195
- function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken) {
129431
+ function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) {
129196
129432
  var _a;
129197
129433
  var previousToken = getRelevantTokens(position, sourceFile).previousToken;
129198
129434
  if (triggerCharacter && !ts.isInString(sourceFile, position, previousToken) && !isValidTrigger(sourceFile, triggerCharacter, previousToken, position)) {
@@ -129232,7 +129468,7 @@ var ts;
129232
129468
  }
129233
129469
  switch (completionData.kind) {
129234
129470
  case 0 /* Data */:
129235
- var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences);
129471
+ var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
129236
129472
  if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
129237
129473
  incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
129238
129474
  }
@@ -129352,7 +129588,7 @@ var ts;
129352
129588
  // StringLiteralLike locations are handled separately in stringCompletions.ts
129353
129589
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
129354
129590
  }
129355
- function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) {
129591
+ function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
129356
129592
  var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
129357
129593
  // Verify if the file is JSX language variant
129358
129594
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
@@ -129364,7 +129600,7 @@ var ts;
129364
129600
  var entries = ts.createSortedArray();
129365
129601
  if (isUncheckedFile(sourceFile, compilerOptions)) {
129366
129602
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
129367
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
129603
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
129368
129604
  getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
129369
129605
  }
129370
129606
  else {
@@ -129372,7 +129608,7 @@ var ts;
129372
129608
  return undefined;
129373
129609
  }
129374
129610
  getCompletionEntriesFromSymbols(symbols, entries,
129375
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
129611
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
129376
129612
  }
129377
129613
  if (keywordFilters !== 0 /* None */) {
129378
129614
  var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
@@ -129478,7 +129714,7 @@ var ts;
129478
129714
  function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
129479
129715
  return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
129480
129716
  }
129481
- function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) {
129717
+ function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext) {
129482
129718
  var _a, _b;
129483
129719
  var insertText;
129484
129720
  var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
@@ -129543,7 +129779,7 @@ var ts;
129543
129779
  completionKind === 3 /* MemberLike */ &&
129544
129780
  isClassLikeMemberCompletion(symbol, location)) {
129545
129781
  var importAdder = void 0;
129546
- (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
129782
+ (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
129547
129783
  if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
129548
129784
  hasAction = true;
129549
129785
  source = CompletionSource.ClassMemberSnippet;
@@ -129642,7 +129878,7 @@ var ts;
129642
129878
  ts.isSyntaxList(location) &&
129643
129879
  ts.isClassLike(location.parent)));
129644
129880
  }
129645
- function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken) {
129881
+ function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext) {
129646
129882
  var classLikeDeclaration = ts.findAncestor(location, ts.isClassLike);
129647
129883
  if (!classLikeDeclaration) {
129648
129884
  return { insertText: name };
@@ -129659,15 +129895,16 @@ var ts;
129659
129895
  newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
129660
129896
  });
129661
129897
  var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
129898
+ // Create empty body for possible method implementation.
129662
129899
  var body;
129663
129900
  if (preferences.includeCompletionsWithSnippetText) {
129664
129901
  isSnippet = true;
129665
129902
  // We are adding a tabstop (i.e. `$0`) in the body of the suggested member,
129666
129903
  // if it has one, so that the cursor ends up in the body once the completion is inserted.
129667
129904
  // Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
129668
- var emptyStatement = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
129669
- ts.setSnippetElement(emptyStatement, { kind: 0 /* TabStop */, order: 0 });
129670
- body = ts.factory.createBlock([emptyStatement], /* multiline */ true);
129905
+ var emptyStmt = ts.factory.createEmptyStatement();
129906
+ body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
129907
+ ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
129671
129908
  }
129672
129909
  else {
129673
129910
  body = ts.factory.createBlock([], /* multiline */ true);
@@ -129713,7 +129950,27 @@ var ts;
129713
129950
  completionNodes.push(node);
129714
129951
  }, body, 2 /* Property */, isAbstract);
129715
129952
  if (completionNodes.length) {
129716
- insertText = printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
129953
+ // If we have access to formatting settings, we print the nodes using the emitter,
129954
+ // and then format the printed text.
129955
+ if (formatContext) {
129956
+ var syntheticFile_1 = {
129957
+ text: printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile),
129958
+ getLineAndCharacterOfPosition: function (pos) {
129959
+ return ts.getLineAndCharacterOfPosition(this, pos);
129960
+ },
129961
+ };
129962
+ var formatOptions_1 = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
129963
+ var changes = ts.flatMap(completionNodes, function (node) {
129964
+ var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
129965
+ return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile_1, sourceFile.languageVariant,
129966
+ /* indentation */ 0,
129967
+ /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions_1 }));
129968
+ });
129969
+ insertText = ts.textChanges.applyChanges(syntheticFile_1.text, changes);
129970
+ }
129971
+ else { // Otherwise, just use emitter to print the new nodes.
129972
+ insertText = printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
129973
+ }
129717
129974
  }
129718
129975
  return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder };
129719
129976
  }
@@ -129757,8 +130014,8 @@ var ts;
129757
130014
  return undefined;
129758
130015
  }
129759
130016
  function createSnippetPrinter(printerOptions) {
129760
- var printer = ts.createPrinter(printerOptions);
129761
- var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions));
130017
+ var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
130018
+ var printer = ts.createPrinter(printerOptions, baseWriter);
129762
130019
  var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } });
129763
130020
  return {
129764
130021
  printSnippetList: printSnippetList,
@@ -129863,7 +130120,7 @@ var ts;
129863
130120
  return CompletionSource.ThisProperty;
129864
130121
  }
129865
130122
  }
129866
- function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
130123
+ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
129867
130124
  var _a;
129868
130125
  var start = ts.timestamp();
129869
130126
  var variableDeclaration = getVariableDeclaration(location);
@@ -129884,7 +130141,7 @@ var ts;
129884
130141
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
129885
130142
  var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
129886
130143
  var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
129887
- var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind);
130144
+ var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext);
129888
130145
  if (!entry) {
129889
130146
  continue;
129890
130147
  }
@@ -130080,7 +130337,7 @@ var ts;
130080
130337
  }
130081
130338
  }
130082
130339
  if (source === CompletionSource.ClassMemberSnippet) {
130083
- var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken).importAdder;
130340
+ var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken, formatContext).importAdder;
130084
130341
  if (importAdder) {
130085
130342
  var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
130086
130343
  return {
@@ -136162,7 +136419,7 @@ var ts;
136162
136419
  : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew);
136163
136420
  // Need an update if the imported file moved, or the importing file moved and was using a relative path.
136164
136421
  return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text)))
136165
- ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
136422
+ ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), sourceFile, getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
136166
136423
  : undefined;
136167
136424
  });
136168
136425
  };
@@ -137807,6 +138064,9 @@ var ts;
137807
138064
  // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes.
137808
138065
  // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'!
137809
138066
  function areSameModule(a, b) {
138067
+ if (!a.body || !b.body) {
138068
+ return a.body === b.body;
138069
+ }
137810
138070
  return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body));
137811
138071
  }
137812
138072
  /** Merge source into target. Source should be thrown away after this is called. */
@@ -145964,19 +146224,13 @@ var ts;
145964
146224
  + ((!options.suffix || ts.endsWith(noIndent, options.suffix))
145965
146225
  ? "" : options.suffix);
145966
146226
  }
145967
- function getFormatCodeSettingsForWriting(_a, sourceFile) {
145968
- var options = _a.options;
145969
- var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore;
145970
- var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile);
145971
- return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
145972
- }
145973
146227
  /** Note: this may mutate `nodeIn`. */
145974
146228
  function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) {
145975
146229
  var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta;
145976
146230
  var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text;
145977
146231
  if (validate)
145978
146232
  validate(node, text);
145979
- var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile);
146233
+ var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
145980
146234
  var initialIndentation = indentation !== undefined
145981
146235
  ? indentation
145982
146236
  : ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos);
@@ -146024,6 +146278,7 @@ var ts;
146024
146278
  ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node));
146025
146279
  return newNode;
146026
146280
  }
146281
+ textChanges_3.assignPositionsToNode = assignPositionsToNode;
146027
146282
  function assignPositionsToNodeArray(nodes, visitor, test, start, count) {
146028
146283
  var visited = ts.visitNodes(nodes, visitor, test, start, count);
146029
146284
  if (!visited) {
@@ -146194,6 +146449,7 @@ var ts;
146194
146449
  clear: clear
146195
146450
  };
146196
146451
  }
146452
+ textChanges_3.createWriter = createWriter;
146197
146453
  function getInsertionPositionAtSourceFileTop(sourceFile) {
146198
146454
  var lastPrologue;
146199
146455
  for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
@@ -150929,7 +151185,8 @@ var ts;
150929
151185
  return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, indentation: undefined, parentDeclaration: parent.initializer };
150930
151186
  }
150931
151187
  if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) {
150932
- var attributes = getUnmatchedAttributes(checker, token.parent);
151188
+ var target = ts.getEmitScriptTarget(program.getCompilerOptions());
151189
+ var attributes = getUnmatchedAttributes(checker, target, token.parent);
150933
151190
  if (!ts.length(attributes))
150934
151191
  return undefined;
150935
151192
  return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
@@ -151164,8 +151421,12 @@ var ts;
151164
151421
  var jsxAttributesNode = info.parentDeclaration.attributes;
151165
151422
  var hasSpreadAttribute = ts.some(jsxAttributesNode.properties, ts.isJsxSpreadAttribute);
151166
151423
  var attrs = ts.map(info.attributes, function (attr) {
151167
- var value = attr.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(attr.valueDeclaration)) : createUndefined();
151168
- return ts.factory.createJsxAttribute(ts.factory.createIdentifier(attr.name), ts.factory.createJsxExpression(/*dotDotDotToken*/ undefined, value));
151424
+ var value = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(attr));
151425
+ var name = ts.factory.createIdentifier(attr.name);
151426
+ var jsxAttribute = ts.factory.createJsxAttribute(name, ts.factory.createJsxExpression(/*dotDotDotToken*/ undefined, value));
151427
+ // formattingScanner requires the Identifier to have a context for scanning attributes with "-" (data-foo).
151428
+ ts.setParent(name, jsxAttribute);
151429
+ return jsxAttribute;
151169
151430
  });
151170
151431
  var jsxAttributes = ts.factory.createJsxAttributes(hasSpreadAttribute ? __spreadArray(__spreadArray([], attrs, true), jsxAttributesNode.properties, true) : __spreadArray(__spreadArray([], jsxAttributesNode.properties, true), attrs, true));
151171
151432
  var options = { prefix: jsxAttributesNode.pos === jsxAttributesNode.end ? " " : undefined };
@@ -151174,10 +151435,11 @@ var ts;
151174
151435
  function addObjectLiteralProperties(changes, context, info) {
151175
151436
  var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
151176
151437
  var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
151438
+ var target = ts.getEmitScriptTarget(context.program.getCompilerOptions());
151177
151439
  var checker = context.program.getTypeChecker();
151178
151440
  var props = ts.map(info.properties, function (prop) {
151179
- var initializer = prop.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(prop.valueDeclaration)) : createUndefined();
151180
- return ts.factory.createPropertyAssignment(prop.name, initializer);
151441
+ var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop));
151442
+ return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer);
151181
151443
  });
151182
151444
  var options = {
151183
151445
  leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude,
@@ -151264,7 +151526,7 @@ var ts;
151264
151526
  return (type.flags & 524288 /* Object */) &&
151265
151527
  ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode)));
151266
151528
  }
151267
- function getUnmatchedAttributes(checker, source) {
151529
+ function getUnmatchedAttributes(checker, target, source) {
151268
151530
  var attrsType = checker.getContextualType(source.attributes);
151269
151531
  if (attrsType === undefined)
151270
151532
  return ts.emptyArray;
@@ -151286,7 +151548,7 @@ var ts;
151286
151548
  }
151287
151549
  }
151288
151550
  return ts.filter(targetProps, function (targetProp) {
151289
- return !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName));
151551
+ return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName));
151290
151552
  });
151291
151553
  }
151292
151554
  })(codefix = ts.codefix || (ts.codefix = {}));
@@ -155019,7 +155281,7 @@ var ts;
155019
155281
  defaultToNamedAction.kind,
155020
155282
  namedToDefaultAction.kind
155021
155283
  ],
155022
- getAvailableActions: function (context) {
155284
+ getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndDefaultExports(context) {
155023
155285
  var info = getInfo(context, context.triggerReason === "invoked");
155024
155286
  if (!info)
155025
155287
  return ts.emptyArray;
@@ -155037,7 +155299,7 @@ var ts;
155037
155299
  }
155038
155300
  return ts.emptyArray;
155039
155301
  },
155040
- getEditsForAction: function (context, actionName) {
155302
+ getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndDefaultExports(context, actionName) {
155041
155303
  ts.Debug.assert(actionName === defaultToNamedAction.name || actionName === namedToDefaultAction.name, "Unexpected action name");
155042
155304
  var info = getInfo(context);
155043
155305
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -155265,7 +155527,7 @@ var ts;
155265
155527
  namespaceToNamedAction.kind,
155266
155528
  namedToNamespaceAction.kind
155267
155529
  ],
155268
- getAvailableActions: function (context) {
155530
+ getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
155269
155531
  var info = getImportToConvert(context, context.triggerReason === "invoked");
155270
155532
  if (!info)
155271
155533
  return ts.emptyArray;
@@ -155284,7 +155546,7 @@ var ts;
155284
155546
  }
155285
155547
  return ts.emptyArray;
155286
155548
  },
155287
- getEditsForAction: function (context, actionName) {
155549
+ getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
155288
155550
  ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
155289
155551
  var info = getImportToConvert(context);
155290
155552
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -155450,10 +155712,10 @@ var ts;
155450
155712
  };
155451
155713
  refactor.registerRefactor(refactorName, {
155452
155714
  kinds: [toOptionalChainAction.kind],
155453
- getAvailableActions: getAvailableActions,
155454
- getEditsForAction: getEditsForAction
155715
+ getEditsForAction: getRefactorEditsToConvertToOptionalChain,
155716
+ getAvailableActions: getRefactorActionsToConvertToOptionalChain,
155455
155717
  });
155456
- function getAvailableActions(context) {
155718
+ function getRefactorActionsToConvertToOptionalChain(context) {
155457
155719
  var info = getInfo(context, context.triggerReason === "invoked");
155458
155720
  if (!info)
155459
155721
  return ts.emptyArray;
@@ -155473,7 +155735,7 @@ var ts;
155473
155735
  }
155474
155736
  return ts.emptyArray;
155475
155737
  }
155476
- function getEditsForAction(context, actionName) {
155738
+ function getRefactorEditsToConvertToOptionalChain(context, actionName) {
155477
155739
  var info = getInfo(context);
155478
155740
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
155479
155741
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) {
@@ -155716,10 +155978,10 @@ var ts;
155716
155978
  };
155717
155979
  refactor.registerRefactor(refactorName, {
155718
155980
  kinds: [functionOverloadAction.kind],
155719
- getEditsForAction: getEditsForAction,
155720
- getAvailableActions: getAvailableActions
155981
+ getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
155982
+ getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
155721
155983
  });
155722
- function getAvailableActions(context) {
155984
+ function getRefactorActionsToConvertOverloadsToOneSignature(context) {
155723
155985
  var file = context.file, startPosition = context.startPosition, program = context.program;
155724
155986
  var info = getConvertableOverloadListAtPosition(file, startPosition, program);
155725
155987
  if (!info)
@@ -155730,7 +155992,7 @@ var ts;
155730
155992
  actions: [functionOverloadAction]
155731
155993
  }];
155732
155994
  }
155733
- function getEditsForAction(context) {
155995
+ function getRefactorEditsToConvertOverloadsToOneSignature(context) {
155734
155996
  var file = context.file, startPosition = context.startPosition, program = context.program;
155735
155997
  var signatureDecls = getConvertableOverloadListAtPosition(file, startPosition, program);
155736
155998
  if (!signatureDecls)
@@ -155886,14 +156148,14 @@ var ts;
155886
156148
  extractConstantAction.kind,
155887
156149
  extractFunctionAction.kind
155888
156150
  ],
155889
- getAvailableActions: getAvailableActions,
155890
- getEditsForAction: getEditsForAction
156151
+ getEditsForAction: getRefactorEditsToExtractSymbol,
156152
+ getAvailableActions: getRefactorActionsToExtractSymbol,
155891
156153
  });
155892
156154
  /**
155893
156155
  * Compute the associated code actions
155894
156156
  * Exported for tests.
155895
156157
  */
155896
- function getAvailableActions(context) {
156158
+ function getRefactorActionsToExtractSymbol(context) {
155897
156159
  var requestedRefactor = context.kind;
155898
156160
  var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context), context.triggerReason === "invoked");
155899
156161
  var targetRange = rangeToExtract.targetRange;
@@ -156022,9 +156284,9 @@ var ts;
156022
156284
  return error;
156023
156285
  }
156024
156286
  }
156025
- extractSymbol.getAvailableActions = getAvailableActions;
156287
+ extractSymbol.getRefactorActionsToExtractSymbol = getRefactorActionsToExtractSymbol;
156026
156288
  /* Exported for tests */
156027
- function getEditsForAction(context, actionName) {
156289
+ function getRefactorEditsToExtractSymbol(context, actionName) {
156028
156290
  var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context));
156029
156291
  var targetRange = rangeToExtract.targetRange; // TODO:GH#18217
156030
156292
  var parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName);
@@ -156041,7 +156303,7 @@ var ts;
156041
156303
  }
156042
156304
  ts.Debug.fail("Unrecognized action name");
156043
156305
  }
156044
- extractSymbol.getEditsForAction = getEditsForAction;
156306
+ extractSymbol.getRefactorEditsToExtractSymbol = getRefactorEditsToExtractSymbol;
156045
156307
  // Move these into diagnostic messages if they become user-facing
156046
156308
  var Messages;
156047
156309
  (function (Messages) {
@@ -157592,7 +157854,7 @@ var ts;
157592
157854
  extractToInterfaceAction.kind,
157593
157855
  extractToTypeDefAction.kind
157594
157856
  ],
157595
- getAvailableActions: function (context) {
157857
+ getAvailableActions: function getRefactorActionsToExtractType(context) {
157596
157858
  var info = getRangeToExtract(context, context.triggerReason === "invoked");
157597
157859
  if (!info)
157598
157860
  return ts.emptyArray;
@@ -157617,7 +157879,7 @@ var ts;
157617
157879
  }
157618
157880
  return ts.emptyArray;
157619
157881
  },
157620
- getEditsForAction: function (context, actionName) {
157882
+ getEditsForAction: function getRefactorEditsToExtractType(context, actionName) {
157621
157883
  var file = context.file;
157622
157884
  var info = getRangeToExtract(context);
157623
157885
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected to find a range to extract");
@@ -157785,7 +158047,7 @@ var ts;
157785
158047
  };
157786
158048
  refactor.registerRefactor(actionName, {
157787
158049
  kinds: [generateGetSetAction.kind],
157788
- getEditsForAction: function (context, actionName) {
158050
+ getEditsForAction: function getRefactorActionsToGenerateGetAndSetAccessors(context, actionName) {
157789
158051
  if (!context.endPosition)
157790
158052
  return undefined;
157791
158053
  var info = ts.codefix.getAccessorConvertiblePropertyAtPosition(context.file, context.program, context.startPosition, context.endPosition);
@@ -157864,7 +158126,7 @@ var ts;
157864
158126
  };
157865
158127
  refactor.registerRefactor(refactorName, {
157866
158128
  kinds: [moveToNewFileAction.kind],
157867
- getAvailableActions: function (context) {
158129
+ getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
157868
158130
  var statements = getStatementsToMove(context);
157869
158131
  if (context.preferences.allowTextChangesInNewFiles && statements) {
157870
158132
  return [{ name: refactorName, description: description, actions: [moveToNewFileAction] }];
@@ -157875,7 +158137,7 @@ var ts;
157875
158137
  }
157876
158138
  return ts.emptyArray;
157877
158139
  },
157878
- getEditsForAction: function (context, actionName) {
158140
+ getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName) {
157879
158141
  ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked");
157880
158142
  var statements = ts.Debug.checkDefined(getStatementsToMove(context));
157881
158143
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); });
@@ -158606,10 +158868,10 @@ var ts;
158606
158868
  };
158607
158869
  refactor.registerRefactor(refactorName, {
158608
158870
  kinds: [removeBracesAction.kind],
158609
- getEditsForAction: getEditsForAction,
158610
- getAvailableActions: getAvailableActions
158871
+ getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
158872
+ getAvailableActions: getRefactorActionsToRemoveFunctionBraces
158611
158873
  });
158612
- function getAvailableActions(context) {
158874
+ function getRefactorActionsToRemoveFunctionBraces(context) {
158613
158875
  var file = context.file, startPosition = context.startPosition, triggerReason = context.triggerReason;
158614
158876
  var info = getConvertibleArrowFunctionAtPosition(file, startPosition, triggerReason === "invoked");
158615
158877
  if (!info)
@@ -158635,7 +158897,7 @@ var ts;
158635
158897
  }
158636
158898
  return ts.emptyArray;
158637
158899
  }
158638
- function getEditsForAction(context, actionName) {
158900
+ function getRefactorEditsToRemoveFunctionBraces(context, actionName) {
158639
158901
  var file = context.file, startPosition = context.startPosition;
158640
158902
  var info = getConvertibleArrowFunctionAtPosition(file, startPosition);
158641
158903
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -158709,10 +158971,10 @@ var ts;
158709
158971
  };
158710
158972
  refactor.registerRefactor(refactorName, {
158711
158973
  kinds: [toDestructuredAction.kind],
158712
- getEditsForAction: getEditsForAction,
158713
- getAvailableActions: getAvailableActions
158974
+ getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
158975
+ getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
158714
158976
  });
158715
- function getAvailableActions(context) {
158977
+ function getRefactorActionsToConvertParametersToDestructuredObject(context) {
158716
158978
  var file = context.file, startPosition = context.startPosition;
158717
158979
  var isJSFile = ts.isSourceFileJS(file);
158718
158980
  if (isJSFile)
@@ -158726,7 +158988,7 @@ var ts;
158726
158988
  actions: [toDestructuredAction]
158727
158989
  }];
158728
158990
  }
158729
- function getEditsForAction(context, actionName) {
158991
+ function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName) {
158730
158992
  ts.Debug.assert(actionName === refactorName, "Unexpected action name");
158731
158993
  var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host;
158732
158994
  var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
@@ -159236,10 +159498,10 @@ var ts;
159236
159498
  };
159237
159499
  refactor.registerRefactor(refactorName, {
159238
159500
  kinds: [convertStringAction.kind],
159239
- getEditsForAction: getEditsForAction,
159240
- getAvailableActions: getAvailableActions
159501
+ getEditsForAction: getRefactorEditsToConvertToTemplateString,
159502
+ getAvailableActions: getRefactorActionsToConvertToTemplateString
159241
159503
  });
159242
- function getAvailableActions(context) {
159504
+ function getRefactorActionsToConvertToTemplateString(context) {
159243
159505
  var file = context.file, startPosition = context.startPosition;
159244
159506
  var node = getNodeOrParentOfParentheses(file, startPosition);
159245
159507
  var maybeBinary = getParentBinaryExpression(node);
@@ -159265,7 +159527,7 @@ var ts;
159265
159527
  }
159266
159528
  return node;
159267
159529
  }
159268
- function getEditsForAction(context, actionName) {
159530
+ function getRefactorEditsToConvertToTemplateString(context, actionName) {
159269
159531
  var file = context.file, startPosition = context.startPosition;
159270
159532
  var node = getNodeOrParentOfParentheses(file, startPosition);
159271
159533
  switch (actionName) {
@@ -159479,10 +159741,10 @@ var ts;
159479
159741
  toNamedFunctionAction.kind,
159480
159742
  toArrowFunctionAction.kind
159481
159743
  ],
159482
- getEditsForAction: getEditsForAction,
159483
- getAvailableActions: getAvailableActions
159744
+ getEditsForAction: getRefactorEditsToConvertFunctionExpressions,
159745
+ getAvailableActions: getRefactorActionsToConvertFunctionExpressions
159484
159746
  });
159485
- function getAvailableActions(context) {
159747
+ function getRefactorActionsToConvertFunctionExpressions(context) {
159486
159748
  var file = context.file, startPosition = context.startPosition, program = context.program, kind = context.kind;
159487
159749
  var info = getFunctionInfo(file, startPosition, program);
159488
159750
  if (!info)
@@ -159526,7 +159788,7 @@ var ts;
159526
159788
  errors : possibleActions
159527
159789
  }];
159528
159790
  }
159529
- function getEditsForAction(context, actionName) {
159791
+ function getRefactorEditsToConvertFunctionExpressions(context, actionName) {
159530
159792
  var file = context.file, startPosition = context.startPosition, program = context.program;
159531
159793
  var info = getFunctionInfo(file, startPosition, program);
159532
159794
  if (!info)
@@ -159686,10 +159948,10 @@ var ts;
159686
159948
  };
159687
159949
  refactor.registerRefactor(refactorName, {
159688
159950
  kinds: [inferReturnTypeAction.kind],
159689
- getEditsForAction: getEditsForAction,
159690
- getAvailableActions: getAvailableActions
159951
+ getEditsForAction: getRefactorEditsToInferReturnType,
159952
+ getAvailableActions: getRefactorActionsToInferReturnType
159691
159953
  });
159692
- function getEditsForAction(context) {
159954
+ function getRefactorEditsToInferReturnType(context) {
159693
159955
  var info = getInfo(context);
159694
159956
  if (info && !refactor.isRefactorErrorInfo(info)) {
159695
159957
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, t, info.declaration, info.returnTypeNode); });
@@ -159697,7 +159959,7 @@ var ts;
159697
159959
  }
159698
159960
  return undefined;
159699
159961
  }
159700
- function getAvailableActions(context) {
159962
+ function getRefactorActionsToInferReturnType(context) {
159701
159963
  var info = getInfo(context);
159702
159964
  if (!info)
159703
159965
  return ts.emptyArray;
@@ -161091,12 +161353,12 @@ var ts;
161091
161353
  synchronizeHostData();
161092
161354
  return __spreadArray(__spreadArray([], program.getOptionsDiagnostics(cancellationToken), true), program.getGlobalDiagnostics(cancellationToken), true);
161093
161355
  }
161094
- function getCompletionsAtPosition(fileName, position, options) {
161356
+ function getCompletionsAtPosition(fileName, position, options, formattingSettings) {
161095
161357
  if (options === void 0) { options = ts.emptyOptions; }
161096
161358
  // Convert from deprecated options names to new names
161097
161359
  var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions });
161098
161360
  synchronizeHostData();
161099
- return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter, options.triggerKind, cancellationToken);
161361
+ return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter, options.triggerKind, cancellationToken, formattingSettings && ts.formatting.getFormatContext(formattingSettings, host));
161100
161362
  }
161101
161363
  function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences, data) {
161102
161364
  if (preferences === void 0) { preferences = ts.emptyOptions; }
@@ -163259,9 +163521,9 @@ var ts;
163259
163521
  * to provide at the given source position and providing a member completion
163260
163522
  * list if requested.
163261
163523
  */
163262
- LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences) {
163524
+ LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) {
163263
163525
  var _this = this;
163264
- return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences); });
163526
+ return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); });
163265
163527
  };
163266
163528
  /** Get a string based representation of a completion list entry details */
163267
163529
  LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) {