typescript 4.7.0-dev.20220408 → 4.7.0-dev.20220417

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/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220408";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220417";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -4660,7 +4660,6 @@ var ts;
4660
4660
  NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
4661
4661
  NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
4662
4662
  NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
4663
- NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType";
4664
4663
  // Error handling
4665
4664
  NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
4666
4665
  NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
@@ -14966,6 +14965,10 @@ var ts;
14966
14965
  }
14967
14966
  }
14968
14967
  ts.isAnyImportSyntax = isAnyImportSyntax;
14968
+ function isAnyImportOrBareOrAccessedRequire(node) {
14969
+ return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
14970
+ }
14971
+ ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
14969
14972
  function isLateVisibilityPaintedStatement(node) {
14970
14973
  switch (node.kind) {
14971
14974
  case 266 /* ImportDeclaration */:
@@ -16326,17 +16329,13 @@ var ts;
16326
16329
  if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
16327
16330
  return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
16328
16331
  }
16329
- if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
16332
+ if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) &&
16330
16333
  (initializer.expression.kind === 108 /* ThisKeyword */ ||
16331
16334
  ts.isIdentifier(initializer.expression) &&
16332
16335
  (initializer.expression.escapedText === "window" ||
16333
16336
  initializer.expression.escapedText === "self" ||
16334
16337
  initializer.expression.escapedText === "global"))) {
16335
- var nameOrArgument = getNameOrArgument(initializer);
16336
- if (ts.isPrivateIdentifier(nameOrArgument)) {
16337
- ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
16338
- }
16339
- return isSameEntityName(name, nameOrArgument);
16338
+ return isSameEntityName(name, getNameOrArgument(initializer));
16340
16339
  }
16341
16340
  if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
16342
16341
  return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
@@ -16544,14 +16543,14 @@ var ts;
16544
16543
  }
16545
16544
  ts.isFunctionSymbol = isFunctionSymbol;
16546
16545
  function tryGetModuleSpecifierFromDeclaration(node) {
16547
- var _a, _b, _c;
16546
+ var _a, _b;
16548
16547
  switch (node.kind) {
16549
16548
  case 254 /* VariableDeclaration */:
16550
- return node.initializer.arguments[0].text;
16549
+ return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
16551
16550
  case 266 /* ImportDeclaration */:
16552
- return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text;
16551
+ return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
16553
16552
  case 265 /* ImportEqualsDeclaration */:
16554
- return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text;
16553
+ return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
16555
16554
  default:
16556
16555
  ts.Debug.assertNever(node);
16557
16556
  }
@@ -17066,7 +17065,10 @@ var ts;
17066
17065
  return parent.propertyName === node;
17067
17066
  case 275 /* ExportSpecifier */:
17068
17067
  case 285 /* JsxAttribute */:
17069
- // Any name in an export specifier or JSX Attribute
17068
+ case 279 /* JsxSelfClosingElement */:
17069
+ case 280 /* JsxOpeningElement */:
17070
+ case 281 /* JsxClosingElement */:
17071
+ // Any name in an export specifier or JSX Attribute or Jsx Element
17070
17072
  return true;
17071
17073
  }
17072
17074
  return false;
@@ -17082,21 +17084,28 @@ var ts;
17082
17084
  // export = <EntityNameExpression>
17083
17085
  // export default <EntityNameExpression>
17084
17086
  // module.exports = <EntityNameExpression>
17085
- // {<Identifier>}
17086
- // {name: <EntityNameExpression>}
17087
+ // module.exports.x = <EntityNameExpression>
17088
+ // const x = require("...")
17089
+ // const { x } = require("...")
17090
+ // const x = require("...").y
17091
+ // const { x } = require("...").y
17087
17092
  function isAliasSymbolDeclaration(node) {
17088
- return node.kind === 265 /* ImportEqualsDeclaration */ ||
17093
+ if (node.kind === 265 /* ImportEqualsDeclaration */ ||
17089
17094
  node.kind === 264 /* NamespaceExportDeclaration */ ||
17090
17095
  node.kind === 267 /* ImportClause */ && !!node.name ||
17091
17096
  node.kind === 268 /* NamespaceImport */ ||
17092
17097
  node.kind === 274 /* NamespaceExport */ ||
17093
17098
  node.kind === 270 /* ImportSpecifier */ ||
17094
17099
  node.kind === 275 /* ExportSpecifier */ ||
17095
- node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node) ||
17096
- ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17097
- ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) ||
17098
- node.kind === 297 /* ShorthandPropertyAssignment */ ||
17099
- node.kind === 296 /* PropertyAssignment */ && isAliasableExpression(node.initializer);
17100
+ node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
17101
+ return true;
17102
+ }
17103
+ return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17104
+ ts.isPropertyAccessExpression(node)
17105
+ && ts.isBinaryExpression(node.parent)
17106
+ && node.parent.left === node
17107
+ && node.parent.operatorToken.kind === 63 /* EqualsToken */
17108
+ && isAliasableExpression(node.parent.right));
17100
17109
  }
17101
17110
  ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
17102
17111
  function getAliasDeclarationFromName(node) {
@@ -17107,6 +17116,7 @@ var ts;
17107
17116
  case 275 /* ExportSpecifier */:
17108
17117
  case 271 /* ExportAssignment */:
17109
17118
  case 265 /* ImportEqualsDeclaration */:
17119
+ case 274 /* NamespaceExport */:
17110
17120
  return node.parent;
17111
17121
  case 161 /* QualifiedName */:
17112
17122
  do {
@@ -18933,6 +18943,11 @@ var ts;
18933
18943
  (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node);
18934
18944
  }
18935
18945
  ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
18946
+ function isRightSideOfAccessExpression(node) {
18947
+ return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
18948
+ || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node;
18949
+ }
18950
+ ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression;
18936
18951
  function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
18937
18952
  return ts.isQualifiedName(node.parent) && node.parent.right === node
18938
18953
  || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
@@ -19584,6 +19599,41 @@ var ts;
19584
19599
  return expr;
19585
19600
  }
19586
19601
  ts.getLeftmostAccessExpression = getLeftmostAccessExpression;
19602
+ function forEachNameInAccessChainWalkingLeft(name, action) {
19603
+ if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) {
19604
+ return walkAccessExpression(name.parent);
19605
+ }
19606
+ function walkAccessExpression(access) {
19607
+ if (access.kind === 206 /* PropertyAccessExpression */) {
19608
+ var res = action(access.name);
19609
+ if (res !== undefined) {
19610
+ return res;
19611
+ }
19612
+ }
19613
+ else if (access.kind === 207 /* ElementAccessExpression */) {
19614
+ if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) {
19615
+ var res = action(access.argumentExpression);
19616
+ if (res !== undefined) {
19617
+ return res;
19618
+ }
19619
+ }
19620
+ else {
19621
+ // Chain interrupted by non-static-name access 'x[expr()].y.z'
19622
+ return undefined;
19623
+ }
19624
+ }
19625
+ if (isAccessExpression(access.expression)) {
19626
+ return walkAccessExpression(access.expression);
19627
+ }
19628
+ if (ts.isIdentifier(access.expression)) {
19629
+ // End of chain at Identifier 'x.y.z'
19630
+ return action(access.expression);
19631
+ }
19632
+ // End of chain at non-Identifier 'x().y.z'
19633
+ return undefined;
19634
+ }
19635
+ }
19636
+ ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft;
19587
19637
  function getLeftmostExpression(node, stopAtCallExpressions) {
19588
19638
  while (true) {
19589
19639
  switch (node.kind) {
@@ -20531,6 +20581,7 @@ var ts;
20531
20581
  ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
20532
20582
  var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]];
20533
20583
  var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
20584
+ ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
20534
20585
  function getSupportedExtensions(options, extraFileExtensions) {
20535
20586
  var needJsExtensions = options && getAllowJSCompilerOption(options);
20536
20587
  if (!extraFileExtensions || extraFileExtensions.length === 0) {
@@ -21219,6 +21270,11 @@ var ts;
21219
21270
  return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
21220
21271
  }
21221
21272
  ts.getNodeModulePathParts = getNodeModulePathParts;
21273
+ function getParameterTypeNode(parameter) {
21274
+ var _a;
21275
+ return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
21276
+ }
21277
+ ts.getParameterTypeNode = getParameterTypeNode;
21222
21278
  })(ts || (ts = {}));
21223
21279
  /* @internal */
21224
21280
  var ts;
@@ -35372,34 +35428,10 @@ var ts;
35372
35428
  case 20 /* OpenParenToken */: // foo<x>(
35373
35429
  case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
35374
35430
  case 15 /* TemplateHead */: // foo<T> `...${100}...`
35375
- // These tokens can't follow in a call expression, nor can they start an
35376
- // expression. So, consider the type argument list part of an instantiation
35377
- // expression.
35378
- // falls through
35379
- case 27 /* CommaToken */: // foo<x>,
35380
- case 24 /* DotToken */: // foo<x>.
35381
- case 28 /* QuestionDotToken */: // foo<x>?.
35382
- case 21 /* CloseParenToken */: // foo<x>)
35383
- case 23 /* CloseBracketToken */: // foo<x>]
35384
- case 58 /* ColonToken */: // foo<x>:
35385
- case 26 /* SemicolonToken */: // foo<x>;
35386
- case 57 /* QuestionToken */: // foo<x>?
35387
- case 34 /* EqualsEqualsToken */: // foo<x> ==
35388
- case 36 /* EqualsEqualsEqualsToken */: // foo<x> ===
35389
- case 35 /* ExclamationEqualsToken */: // foo<x> !=
35390
- case 37 /* ExclamationEqualsEqualsToken */: // foo<x> !==
35391
- case 55 /* AmpersandAmpersandToken */: // foo<x> &&
35392
- case 56 /* BarBarToken */: // foo<x> ||
35393
- case 60 /* QuestionQuestionToken */: // foo<x> ??
35394
- case 52 /* CaretToken */: // foo<x> ^
35395
- case 50 /* AmpersandToken */: // foo<x> &
35396
- case 51 /* BarToken */: // foo<x> |
35397
- case 19 /* CloseBraceToken */: // foo<x> }
35398
- case 1 /* EndOfFileToken */: // foo<x>
35399
35431
  return true;
35400
35432
  }
35401
- // Treat anything else as an expression.
35402
- return false;
35433
+ // Consider something a type argument list only if the following token can't start an expression.
35434
+ return !isStartOfExpression();
35403
35435
  }
35404
35436
  function parsePrimaryExpression() {
35405
35437
  switch (token()) {
@@ -38617,7 +38649,7 @@ var ts;
38617
38649
  })(IncrementalParser || (IncrementalParser = {}));
38618
38650
  /** @internal */
38619
38651
  function isDeclarationFileName(fileName) {
38620
- return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
38652
+ return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions);
38621
38653
  }
38622
38654
  ts.isDeclarationFileName = isDeclarationFileName;
38623
38655
  function parseResolutionMode(mode, pos, end, reportDiagnostic) {
@@ -42125,7 +42157,8 @@ var ts;
42125
42157
  Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
42126
42158
  Extensions[Extensions["Json"] = 2] = "Json";
42127
42159
  Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
42128
- Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */
42160
+ Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
42161
+ Extensions[Extensions["TsOnly"] = 5] = "TsOnly";
42129
42162
  })(Extensions || (Extensions = {}));
42130
42163
  /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
42131
42164
  function resolvedTypeScriptOnly(resolved) {
@@ -43070,7 +43103,21 @@ var ts;
43070
43103
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43071
43104
  }
43072
43105
  function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
43073
- return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
43106
+ var extensions;
43107
+ if (lookupConfig) {
43108
+ extensions = tsconfigExtensions;
43109
+ }
43110
+ else if (compilerOptions.noDtsResolution) {
43111
+ extensions = [Extensions.TsOnly];
43112
+ if (compilerOptions.allowJs)
43113
+ extensions.push(Extensions.JavaScript);
43114
+ if (compilerOptions.resolveJsonModule)
43115
+ extensions.push(Extensions.Json);
43116
+ }
43117
+ else {
43118
+ extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
43119
+ }
43120
+ return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
43074
43121
  }
43075
43122
  ts.nodeModuleNameResolver = nodeModuleNameResolver;
43076
43123
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
@@ -43079,6 +43126,10 @@ var ts;
43079
43126
  var failedLookupLocations = [];
43080
43127
  // conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
43081
43128
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43129
+ var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
43130
+ if (compilerOptions.noDtsResolution) {
43131
+ conditions.pop();
43132
+ }
43082
43133
  var state = {
43083
43134
  compilerOptions: compilerOptions,
43084
43135
  host: host,
@@ -43086,7 +43137,7 @@ var ts;
43086
43137
  failedLookupLocations: failedLookupLocations,
43087
43138
  packageJsonInfoCache: cache,
43088
43139
  features: features,
43089
- conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
43140
+ conditions: conditions,
43090
43141
  };
43091
43142
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43092
43143
  return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
@@ -43262,9 +43313,9 @@ var ts;
43262
43313
  }
43263
43314
  }
43264
43315
  function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
43265
- if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) {
43316
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
43266
43317
  var result = tryFile(candidate, onlyRecordFailures, state);
43267
- return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
43318
+ return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
43268
43319
  }
43269
43320
  return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
43270
43321
  }
@@ -43294,20 +43345,22 @@ var ts;
43294
43345
  default: return tryExtension(".d.ts" /* Dts */);
43295
43346
  }
43296
43347
  case Extensions.TypeScript:
43348
+ case Extensions.TsOnly:
43349
+ var useDts = extensions === Extensions.TypeScript;
43297
43350
  switch (originalExtension) {
43298
43351
  case ".mjs" /* Mjs */:
43299
43352
  case ".mts" /* Mts */:
43300
43353
  case ".d.mts" /* Dmts */:
43301
- return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
43354
+ return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
43302
43355
  case ".cjs" /* Cjs */:
43303
43356
  case ".cts" /* Cts */:
43304
43357
  case ".d.cts" /* Dcts */:
43305
- return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
43358
+ return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
43306
43359
  case ".json" /* Json */:
43307
43360
  candidate += ".json" /* Json */;
43308
- return tryExtension(".d.ts" /* Dts */);
43361
+ return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
43309
43362
  default:
43310
- return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
43363
+ return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
43311
43364
  }
43312
43365
  case Extensions.JavaScript:
43313
43366
  switch (originalExtension) {
@@ -43534,6 +43587,7 @@ var ts;
43534
43587
  switch (extensions) {
43535
43588
  case Extensions.JavaScript:
43536
43589
  case Extensions.Json:
43590
+ case Extensions.TsOnly:
43537
43591
  packageFile = readPackageJsonMainField(jsonContent, candidate, state);
43538
43592
  break;
43539
43593
  case Extensions.TypeScript:
@@ -43606,14 +43660,16 @@ var ts;
43606
43660
  function extensionIsOk(extensions, extension) {
43607
43661
  switch (extensions) {
43608
43662
  case Extensions.JavaScript:
43609
- return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
43663
+ return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */;
43610
43664
  case Extensions.TSConfig:
43611
43665
  case Extensions.Json:
43612
43666
  return extension === ".json" /* Json */;
43613
43667
  case Extensions.TypeScript:
43614
- return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
43668
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */ || extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
43669
+ case Extensions.TsOnly:
43670
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */;
43615
43671
  case Extensions.DtsOnly:
43616
- return extension === ".d.ts" /* Dts */;
43672
+ return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
43617
43673
  }
43618
43674
  }
43619
43675
  /* @internal */
@@ -52915,9 +52971,6 @@ var ts;
52915
52971
  if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
52916
52972
  parameterType = getOptionalType(parameterType);
52917
52973
  }
52918
- if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
52919
- parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */);
52920
- }
52921
52974
  var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
52922
52975
  var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
52923
52976
  var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
@@ -53476,7 +53529,7 @@ var ts;
53476
53529
  if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
53477
53530
  // try to reuse the existing annotation
53478
53531
  var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
53479
- if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
53532
+ if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
53480
53533
  var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
53481
53534
  if (result_6) {
53482
53535
  return result_6;
@@ -53493,6 +53546,16 @@ var ts;
53493
53546
  context.flags = oldFlags;
53494
53547
  return result;
53495
53548
  }
53549
+ function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
53550
+ var typeFromTypeNode = getTypeFromTypeNode(typeNode);
53551
+ if (typeFromTypeNode === type) {
53552
+ return true;
53553
+ }
53554
+ if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
53555
+ return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
53556
+ }
53557
+ return false;
53558
+ }
53496
53559
  function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
53497
53560
  if (!isErrorType(type) && context.enclosingDeclaration) {
53498
53561
  var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
@@ -55764,7 +55827,7 @@ var ts;
55764
55827
  }
55765
55828
  }
55766
55829
  var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
55767
- type = getUnionType(sourceTypes, 2 /* Subtype */);
55830
+ type = getUnionType(sourceTypes);
55768
55831
  }
55769
55832
  }
55770
55833
  var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
@@ -58513,8 +58576,9 @@ var ts;
58513
58576
  // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
58514
58577
  // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
58515
58578
  // nesting, so it is effectively just a safety stop.
58516
- if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) {
58517
- stack.push(t);
58579
+ var identity_1 = getRecursionIdentity(t);
58580
+ if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
58581
+ stack.push(identity_1);
58518
58582
  result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
58519
58583
  stack.pop();
58520
58584
  }
@@ -66712,12 +66776,12 @@ var ts;
66712
66776
  function isDeeplyNestedType(type, stack, depth, maxDepth) {
66713
66777
  if (maxDepth === void 0) { maxDepth = 3; }
66714
66778
  if (depth >= maxDepth) {
66715
- var identity_1 = getRecursionIdentity(type);
66779
+ var identity_2 = getRecursionIdentity(type);
66716
66780
  var count = 0;
66717
66781
  var lastTypeId = 0;
66718
66782
  for (var i = 0; i < depth; i++) {
66719
66783
  var t = stack[i];
66720
- if (getRecursionIdentity(t) === identity_1) {
66784
+ if (getRecursionIdentity(t) === identity_2) {
66721
66785
  // We only count occurrences with a higher type id than the previous occurrence, since higher
66722
66786
  // type ids are an indicator of newer instantiations caused by recursion.
66723
66787
  if (t.id >= lastTypeId) {
@@ -79531,11 +79595,16 @@ var ts;
79531
79595
  if (constraintType && defaultType) {
79532
79596
  checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
79533
79597
  }
79534
- if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) {
79598
+ checkNodeDeferred(node);
79599
+ addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79600
+ }
79601
+ function checkTypeParameterDeferred(node) {
79602
+ if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) {
79603
+ var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
79535
79604
  var modifiers = getVarianceModifiers(typeParameter);
79536
79605
  if (modifiers) {
79537
79606
  var symbol = getSymbolOfNode(node.parent);
79538
- if (node.parent.kind === 259 /* TypeAliasDeclaration */ && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
79607
+ if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
79539
79608
  error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
79540
79609
  }
79541
79610
  else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
@@ -79548,7 +79617,6 @@ var ts;
79548
79617
  }
79549
79618
  }
79550
79619
  }
79551
- addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79552
79620
  }
79553
79621
  function checkParameter(node) {
79554
79622
  // Grammar checking
@@ -80038,7 +80106,7 @@ var ts;
80038
80106
  superCallStatement = statement;
80039
80107
  break;
80040
80108
  }
80041
- if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
80109
+ if (nodeImmediatelyReferencesSuperOrThis(statement)) {
80042
80110
  break;
80043
80111
  }
80044
80112
  }
@@ -85391,6 +85459,9 @@ var ts;
85391
85459
  case 226 /* ClassExpression */:
85392
85460
  checkClassExpressionDeferred(node);
85393
85461
  break;
85462
+ case 163 /* TypeParameter */:
85463
+ checkTypeParameterDeferred(node);
85464
+ break;
85394
85465
  case 279 /* JsxSelfClosingElement */:
85395
85466
  checkJsxSelfClosingElementDeferred(node);
85396
85467
  break;
@@ -86487,11 +86558,6 @@ var ts;
86487
86558
  !parameter.initializer &&
86488
86559
  ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
86489
86560
  }
86490
- function isOptionalUninitializedParameter(parameter) {
86491
- return !!strictNullChecks &&
86492
- isOptionalParameter(parameter) &&
86493
- !parameter.initializer;
86494
- }
86495
86561
  function isExpandoFunctionDeclaration(node) {
86496
86562
  var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
86497
86563
  if (!declaration) {
@@ -87408,8 +87474,7 @@ var ts;
87408
87474
  case 144 /* OutKeyword */:
87409
87475
  var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */;
87410
87476
  var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out";
87411
- if (node.kind !== 163 /* TypeParameter */ || (node.parent.kind !== 258 /* InterfaceDeclaration */ &&
87412
- node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) {
87477
+ if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) {
87413
87478
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
87414
87479
  }
87415
87480
  if (flags & inOutFlag) {
@@ -92643,11 +92708,11 @@ var ts;
92643
92708
  }
92644
92709
  var statements = [];
92645
92710
  resumeLexicalEnvironment();
92646
- var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
92647
- var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
92711
+ var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
92712
+ var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount);
92648
92713
  // If there was a super call, visit existing statements up to and including it
92649
92714
  if (superStatementIndex >= 0) {
92650
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
92715
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount));
92651
92716
  }
92652
92717
  // Transform parameters into property assignments. Transforms this:
92653
92718
  //
@@ -92666,12 +92731,12 @@ var ts;
92666
92731
  if (superStatementIndex >= 0) {
92667
92732
  ts.addRange(statements, parameterPropertyAssignments);
92668
92733
  }
92669
- // Since there was no super() call, parameter properties are the first statements in the constructor
92734
+ // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements
92670
92735
  else {
92671
- statements = ts.addRange(parameterPropertyAssignments, statements);
92736
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
92672
92737
  }
92673
- // Add remaining statements from the body, skipping the super() call if it was found
92674
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
92738
+ // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
92739
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
92675
92740
  // End the lexical environment.
92676
92741
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
92677
92742
  var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
@@ -109570,7 +109635,7 @@ var ts;
109570
109635
  addOutput(buildInfoPath);
109571
109636
  }
109572
109637
  function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
109573
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
109638
+ if (ts.isDeclarationFileName(inputFileName))
109574
109639
  return;
109575
109640
  var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
109576
109641
  addOutput(js);
@@ -109615,7 +109680,7 @@ var ts;
109615
109680
  /*@internal*/
109616
109681
  function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
109617
109682
  var options = _a.options, fileNames = _a.fileNames;
109618
- return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
109683
+ return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
109619
109684
  }
109620
109685
  ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
109621
109686
  /*@internal*/
@@ -109657,7 +109722,7 @@ var ts;
109657
109722
  var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
109658
109723
  for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
109659
109724
  var inputFileName = _b[_a];
109660
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
109725
+ if (ts.isDeclarationFileName(inputFileName))
109661
109726
  continue;
109662
109727
  var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
109663
109728
  if (jsFilePath)
@@ -115007,7 +115072,7 @@ var ts;
115007
115072
  if (ts.outFile(options) || options.outDir)
115008
115073
  return false;
115009
115074
  // File if emitted next to input needs to be ignored
115010
- if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) {
115075
+ if (ts.isDeclarationFileName(fileOrDirectoryPath)) {
115011
115076
  // If its declaration directory: its not ignored if not excluded by config
115012
115077
  if (options.declarationDir)
115013
115078
  return false;
@@ -116180,7 +116245,7 @@ var ts;
116180
116245
  var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
116181
116246
  for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
116182
116247
  var fileName = _c[_b];
116183
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
116248
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
116184
116249
  processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
116185
116250
  }
116186
116251
  }
@@ -116371,7 +116436,7 @@ var ts;
116371
116436
  }
116372
116437
  function getRedirectReferenceForResolution(file) {
116373
116438
  var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
116374
- if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]))
116439
+ if (redirect || !ts.isDeclarationFileName(file.originalFileName))
116375
116440
  return redirect;
116376
116441
  // The originalFileName could not be actual source file name if file found was d.ts from referecned project
116377
116442
  // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case
@@ -117762,7 +117827,7 @@ var ts;
117762
117827
  }
117763
117828
  function getProjectReferenceRedirectProject(fileName) {
117764
117829
  // Ignore dts or any json files
117765
- if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117830
+ if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117766
117831
  return undefined;
117767
117832
  }
117768
117833
  // If this file is produced by a referenced project, we need to rewrite it to
@@ -117811,7 +117876,7 @@ var ts;
117811
117876
  else {
117812
117877
  var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
117813
117878
  ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
117814
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117879
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117815
117880
  var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
117816
117881
  mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
117817
117882
  }
@@ -118612,7 +118677,7 @@ var ts;
118612
118677
  if (options.outDir) {
118613
118678
  return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
118614
118679
  }
118615
- if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) {
118680
+ if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) {
118616
118681
  // Otherwise just check if sourceFile with the name exists
118617
118682
  var filePathWithoutExtension = ts.removeFileExtension(filePath);
118618
118683
  return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
@@ -118945,13 +119010,9 @@ var ts;
118945
119010
  ts.getFileEmitOutput = getFileEmitOutput;
118946
119011
  var BuilderState;
118947
119012
  (function (BuilderState) {
118948
- var manyToManyPathMapCount = 0;
118949
119013
  function createManyToManyPathMap() {
118950
119014
  function create(forward, reverse, deleted) {
118951
- var version = 0;
118952
119015
  var map = {
118953
- id: manyToManyPathMapCount++,
118954
- version: function () { return version; },
118955
119016
  clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
118956
119017
  forEach: function (fn) { return forward.forEach(fn); },
118957
119018
  getKeys: function (v) { return reverse.get(v); },
@@ -118967,30 +119028,29 @@ var ts;
118967
119028
  }
118968
119029
  set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); });
118969
119030
  forward.delete(k);
118970
- version++;
118971
119031
  return true;
118972
119032
  },
118973
119033
  set: function (k, vSet) {
118974
- var changed = !!(deleted === null || deleted === void 0 ? void 0 : deleted.delete(k));
119034
+ deleted === null || deleted === void 0 ? void 0 : deleted.delete(k);
118975
119035
  var existingVSet = forward.get(k);
118976
119036
  forward.set(k, vSet);
118977
119037
  existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) {
118978
119038
  if (!vSet.has(v)) {
118979
- changed = true;
118980
119039
  deleteFromMultimap(reverse, v, k);
118981
119040
  }
118982
119041
  });
118983
119042
  vSet.forEach(function (v) {
118984
119043
  if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) {
118985
- changed = true;
118986
119044
  addToMultimap(reverse, v, k);
118987
119045
  }
118988
119046
  });
118989
- if (changed) {
118990
- version++;
118991
- }
118992
119047
  return map;
118993
119048
  },
119049
+ clear: function () {
119050
+ forward.clear();
119051
+ reverse.clear();
119052
+ deleted === null || deleted === void 0 ? void 0 : deleted.clear();
119053
+ }
118994
119054
  };
118995
119055
  return map;
118996
119056
  }
@@ -119005,11 +119065,10 @@ var ts;
119005
119065
  }
119006
119066
  set.add(v);
119007
119067
  }
119008
- function deleteFromMultimap(map, k, v, removeEmpty) {
119009
- if (removeEmpty === void 0) { removeEmpty = true; }
119068
+ function deleteFromMultimap(map, k, v) {
119010
119069
  var set = map.get(k);
119011
119070
  if (set === null || set === void 0 ? void 0 : set.delete(v)) {
119012
- if (removeEmpty && !set.size) {
119071
+ if (!set.size) {
119013
119072
  map.delete(k);
119014
119073
  }
119015
119074
  return true;
@@ -119238,7 +119297,7 @@ var ts;
119238
119297
  /*forceDtsEmit*/ true);
119239
119298
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
119240
119299
  if (firstDts_1) {
119241
- ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
119300
+ ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
119242
119301
  latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
119243
119302
  if (exportedModulesMapCache && latestSignature !== prevSignature) {
119244
119303
  updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
@@ -119296,20 +119355,6 @@ var ts;
119296
119355
  var _a;
119297
119356
  if (exportedModulesMapCache) {
119298
119357
  ts.Debug.assert(!!state.exportedModulesMap);
119299
- var cacheId = exportedModulesMapCache.id;
119300
- var cacheVersion = exportedModulesMapCache.version();
119301
- if (state.previousCache) {
119302
- if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) {
119303
- // If this is the same cache at the same version as last time this BuilderState
119304
- // was updated, there's no need to update again
119305
- return;
119306
- }
119307
- state.previousCache.id = cacheId;
119308
- state.previousCache.version = cacheVersion;
119309
- }
119310
- else {
119311
- state.previousCache = { id: cacheId, version: cacheVersion };
119312
- }
119313
119358
  (_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
119314
119359
  exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
119315
119360
  }
@@ -119643,7 +119688,8 @@ var ts;
119643
119688
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
119644
119689
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
119645
119690
  */
119646
- function getNextAffectedFile(state, cancellationToken, computeHash) {
119691
+ function getNextAffectedFile(state, cancellationToken, computeHash, host) {
119692
+ var _a;
119647
119693
  while (true) {
119648
119694
  var affectedFiles = state.affectedFiles;
119649
119695
  if (affectedFiles) {
@@ -119654,7 +119700,7 @@ var ts;
119654
119700
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
119655
119701
  // Set the next affected file as seen and remove the cached semantic diagnostics
119656
119702
  state.affectedFilesIndex = affectedFilesIndex;
119657
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
119703
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
119658
119704
  return affectedFile;
119659
119705
  }
119660
119706
  affectedFilesIndex++;
@@ -119666,6 +119712,7 @@ var ts;
119666
119712
  ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
119667
119713
  state.currentAffectedFilesSignatures.clear();
119668
119714
  ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
119715
+ (_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
119669
119716
  state.affectedFiles = undefined;
119670
119717
  }
119671
119718
  // Get next changed file
@@ -119695,6 +119742,11 @@ var ts;
119695
119742
  state.seenAffectedFiles = new ts.Set();
119696
119743
  }
119697
119744
  }
119745
+ function clearAffectedFilesPendingEmit(state) {
119746
+ state.affectedFilesPendingEmit = undefined;
119747
+ state.affectedFilesPendingEmitKind = undefined;
119748
+ state.affectedFilesPendingEmitIndex = undefined;
119749
+ }
119698
119750
  /**
119699
119751
  * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
119700
119752
  */
@@ -119714,9 +119766,7 @@ var ts;
119714
119766
  }
119715
119767
  }
119716
119768
  }
119717
- state.affectedFilesPendingEmit = undefined;
119718
- state.affectedFilesPendingEmitKind = undefined;
119719
- state.affectedFilesPendingEmitIndex = undefined;
119769
+ clearAffectedFilesPendingEmit(state);
119720
119770
  }
119721
119771
  return undefined;
119722
119772
  }
@@ -119724,7 +119774,7 @@ var ts;
119724
119774
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
119725
119775
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
119726
119776
  */
119727
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
119777
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
119728
119778
  var _a;
119729
119779
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
119730
119780
  // If affected files is everything except default library, then nothing more to do
@@ -119749,14 +119799,14 @@ var ts;
119749
119799
  ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
119750
119800
  }
119751
119801
  if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
119752
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
119802
+ forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
119753
119803
  }
119754
119804
  }
119755
119805
  /**
119756
119806
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
119757
119807
  * Also we need to make sure signature is updated for these files
119758
119808
  */
119759
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
119809
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
119760
119810
  removeSemanticDiagnosticsOf(state, path);
119761
119811
  if (!state.changedFilesSet.has(path)) {
119762
119812
  var program = ts.Debug.checkDefined(state.program);
@@ -119767,8 +119817,7 @@ var ts;
119767
119817
  // This ensures that we dont later during incremental builds considering wrong signature.
119768
119818
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
119769
119819
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
119770
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap,
119771
- /* useFileVersionAsSignature */ true);
119820
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
119772
119821
  // If not dts emit, nothing more to do
119773
119822
  if (ts.getEmitDeclarations(state.compilerOptions)) {
119774
119823
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -119965,13 +120014,18 @@ var ts;
119965
120014
  var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
119966
120015
  var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
119967
120016
  return value.version === actualSignature ?
119968
- value.affectsGlobalScope ?
119969
- { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
120017
+ value.affectsGlobalScope || value.impliedFormat ?
120018
+ // If file version is same as signature, dont serialize signature
120019
+ { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120020
+ // If file info only contains version and signature and both are same we can just write string
119970
120021
  value.version :
119971
- actualSignature !== undefined ?
120022
+ actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
119972
120023
  signature === undefined ?
120024
+ // If we havent computed signature, use fileInfo as is
119973
120025
  value :
120026
+ // Serialize fileInfo with new updated signature
119974
120027
  { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120028
+ // Signature of the FileInfo is undefined, serialize it as false
119975
120029
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
119976
120030
  });
119977
120031
  var referencedMap;
@@ -120216,7 +120270,7 @@ var ts;
120216
120270
  * in that order would be used to write the files
120217
120271
  */
120218
120272
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
120219
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
120273
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
120220
120274
  var emitKind = 1 /* Full */;
120221
120275
  var isPendingEmitFile = false;
120222
120276
  if (!affected) {
@@ -120261,54 +120315,48 @@ var ts;
120261
120315
  * in that order would be used to write the files
120262
120316
  */
120263
120317
  function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
120264
- var restorePendingEmitOnHandlingNoEmitSuccess = false;
120265
- var savedAffectedFilesPendingEmit;
120266
- var savedAffectedFilesPendingEmitKind;
120267
- var savedAffectedFilesPendingEmitIndex;
120268
- // Backup and restore affected pendings emit state for non emit Builder if noEmitOnError is enabled and emitBuildInfo could be written in case there are errors
120269
- // This ensures pending files to emit is updated in tsbuildinfo
120270
- // Note that when there are no errors, emit proceeds as if everything is emitted as it is callers reponsibility to write the files to disk if at all (because its builder that doesnt track files to emit)
120271
- if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
120272
- !targetSourceFile &&
120273
- !ts.outFile(state.compilerOptions) &&
120274
- !state.compilerOptions.noEmit &&
120275
- state.compilerOptions.noEmitOnError) {
120276
- restorePendingEmitOnHandlingNoEmitSuccess = true;
120277
- savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120278
- savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120279
- savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120280
- }
120318
+ var _a;
120281
120319
  if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120282
120320
  assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
120283
120321
  }
120284
120322
  var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
120285
120323
  if (result)
120286
120324
  return result;
120287
- if (restorePendingEmitOnHandlingNoEmitSuccess) {
120288
- state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
120289
- state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
120290
- state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
120291
- }
120292
120325
  // Emit only affected files if using builder for emit
120293
- if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120294
- // Emit and report any errors we ran into.
120295
- var sourceMaps = [];
120296
- var emitSkipped = false;
120297
- var diagnostics = void 0;
120298
- var emittedFiles = [];
120299
- var affectedEmitResult = void 0;
120300
- while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
120301
- emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
120302
- diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
120303
- emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
120304
- sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
120326
+ if (!targetSourceFile) {
120327
+ if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120328
+ // Emit and report any errors we ran into.
120329
+ var sourceMaps = [];
120330
+ var emitSkipped = false;
120331
+ var diagnostics = void 0;
120332
+ var emittedFiles = [];
120333
+ var affectedEmitResult = void 0;
120334
+ while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
120335
+ emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
120336
+ diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
120337
+ emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
120338
+ sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
120339
+ }
120340
+ return {
120341
+ emitSkipped: emitSkipped,
120342
+ diagnostics: diagnostics || ts.emptyArray,
120343
+ emittedFiles: emittedFiles,
120344
+ sourceMaps: sourceMaps
120345
+ };
120346
+ }
120347
+ // In non Emit builder, clear affected files pending emit
120348
+ else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) {
120349
+ ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram);
120350
+ // State can clear affected files pending emit if
120351
+ if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared
120352
+ // If every file pending emit is pending on only dts emit
120353
+ || ts.every(state.affectedFilesPendingEmit, function (path, index) {
120354
+ return index < state.affectedFilesPendingEmitIndex ||
120355
+ state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */;
120356
+ })) {
120357
+ clearAffectedFilesPendingEmit(state);
120358
+ }
120305
120359
  }
120306
- return {
120307
- emitSkipped: emitSkipped,
120308
- diagnostics: diagnostics || ts.emptyArray,
120309
- emittedFiles: emittedFiles,
120310
- sourceMaps: sourceMaps
120311
- };
120312
120360
  }
120313
120361
  return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120314
120362
  }
@@ -120318,7 +120366,7 @@ var ts;
120318
120366
  */
120319
120367
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
120320
120368
  while (true) {
120321
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
120369
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
120322
120370
  if (!affected) {
120323
120371
  // Done
120324
120372
  return undefined;
@@ -123438,9 +123486,6 @@ var ts;
123438
123486
  function newer(date1, date2) {
123439
123487
  return date2 > date1 ? date2 : date1;
123440
123488
  }
123441
- function isDeclarationFile(fileName) {
123442
- return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
123443
- }
123444
123489
  /*@internal*/
123445
123490
  function isCircularBuildOrder(buildOrder) {
123446
123491
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124003,7 +124048,7 @@ var ts;
124003
124048
  outputFiles.forEach(function (_a) {
124004
124049
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124005
124050
  var priorChangeTime;
124006
- if (!anyDtsChanged && isDeclarationFile(name)) {
124051
+ if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
124007
124052
  // Check for unchanged .d.ts files
124008
124053
  if (host.fileExists(name) && state.readFileWithCache(name) === text) {
124009
124054
  priorChangeTime = host.getModifiedTime(name);
@@ -124344,7 +124389,7 @@ var ts;
124344
124389
  // In addition to file timestamps, we also keep track of when a .d.ts file
124345
124390
  // had its file touched but not had its contents changed - this allows us
124346
124391
  // to skip a downstream typecheck
124347
- if (isDeclarationFile(output)) {
124392
+ if (ts.isDeclarationFileName(output)) {
124348
124393
  var outputModifiedTime = ts.getModifiedTime(host, output);
124349
124394
  newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
124350
124395
  }
@@ -124498,7 +124543,7 @@ var ts;
124498
124543
  reportVerbose = false;
124499
124544
  reportStatus(state, verboseMessage, proj.options.configFilePath);
124500
124545
  }
124501
- if (isDeclarationFile(file)) {
124546
+ if (ts.isDeclarationFileName(file)) {
124502
124547
  priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
124503
124548
  }
124504
124549
  host.setModifiedTime(file, now);
@@ -131393,17 +131438,13 @@ var ts;
131393
131438
  }
131394
131439
  }
131395
131440
  if (origin && originIsObjectLiteralMethod(origin)) {
131396
- var importAdder = void 0;
131397
- (insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails);
131441
+ (insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails);
131398
131442
  if (!preferences.useLabelDetailsInCompletionEntries) {
131399
131443
  name = name + labelDetails.detail;
131400
131444
  labelDetails = undefined;
131401
131445
  }
131402
131446
  source = CompletionSource.ObjectLiteralMethodSnippet;
131403
131447
  sortText = Completions.SortText.SortBelow(sortText);
131404
- if (importAdder.hasFixes()) {
131405
- hasAction = true;
131406
- }
131407
131448
  }
131408
131449
  if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
131409
131450
  var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
@@ -131626,8 +131667,7 @@ var ts;
131626
131667
  var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
131627
131668
  var insertText = name;
131628
131669
  var sourceFile = enclosingDeclaration.getSourceFile();
131629
- var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
131630
- var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
131670
+ var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences);
131631
131671
  if (!method) {
131632
131672
  return undefined;
131633
131673
  }
@@ -131656,16 +131696,15 @@ var ts;
131656
131696
  /*modifiers*/ undefined,
131657
131697
  /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type);
131658
131698
  var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) };
131659
- return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, labelDetails: labelDetails };
131699
+ return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
131660
131700
  }
131661
131701
  ;
131662
- function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) {
131702
+ function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
131663
131703
  var declarations = symbol.getDeclarations();
131664
131704
  if (!(declarations && declarations.length)) {
131665
131705
  return undefined;
131666
131706
  }
131667
131707
  var checker = program.getTypeChecker();
131668
- var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
131669
131708
  var declaration = declarations[0];
131670
131709
  var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
131671
131710
  var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
@@ -131698,11 +131737,6 @@ var ts;
131698
131737
  if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
131699
131738
  return undefined;
131700
131739
  }
131701
- var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
131702
- if (importableReference) {
131703
- typeNode = importableReference.typeNode;
131704
- ts.codefix.importSymbols(importAdder, importableReference.symbols);
131705
- }
131706
131740
  var body = void 0;
131707
131741
  if (preferences.includeCompletionsWithSnippetText) {
131708
131742
  var emptyStmt = ts.factory.createEmptyStatement();
@@ -131712,11 +131746,19 @@ var ts;
131712
131746
  else {
131713
131747
  body = ts.factory.createBlock([], /* multiline */ true);
131714
131748
  }
131749
+ var parameters = typeNode.parameters.map(function (typedParam) {
131750
+ return ts.factory.createParameterDeclaration(
131751
+ /*decorators*/ undefined,
131752
+ /*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken,
131753
+ /*type*/ undefined, typedParam.initializer);
131754
+ });
131715
131755
  return ts.factory.createMethodDeclaration(
131716
131756
  /*decorators*/ undefined,
131717
131757
  /*modifiers*/ undefined,
131718
131758
  /*asteriskToken*/ undefined, name,
131719
- /*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body);
131759
+ /*questionToken*/ undefined,
131760
+ /*typeParameters*/ undefined, parameters,
131761
+ /*type*/ undefined, body);
131720
131762
  }
131721
131763
  default:
131722
131764
  return undefined;
@@ -132079,20 +132121,6 @@ var ts;
132079
132121
  };
132080
132122
  }
132081
132123
  }
132082
- if (source === CompletionSource.ObjectLiteralMethodSnippet) {
132083
- var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
132084
- var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
132085
- if (importAdder.hasFixes()) {
132086
- var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
132087
- return {
132088
- sourceDisplay: undefined,
132089
- codeActions: [{
132090
- changes: changes,
132091
- description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
132092
- }],
132093
- };
132094
- }
132095
- }
132096
132124
  if (originIsTypeOnlyAlias(origin)) {
132097
132125
  var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
132098
132126
  ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
@@ -134913,7 +134941,7 @@ var ts;
134913
134941
  // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
134914
134942
  // If this occurs unexpectedly, the fix is likely to synchronize the project settings.
134915
134943
  // Skip .d.ts files to reduce noise (should also cover most of node_modules).
134916
- var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) &&
134944
+ var otherBucketKey = !ts.isDeclarationFileName(path) &&
134917
134945
  ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
134918
134946
  if (otherBucketKey) {
134919
134947
  ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
@@ -136853,6 +136881,30 @@ var ts;
136853
136881
  }
136854
136882
  }
136855
136883
  Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
136884
+ function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
136885
+ var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
136886
+ return candidates.reduce(function (topMost, decl) {
136887
+ var depth = getDepth(decl);
136888
+ if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
136889
+ topMost.declarationNames.push(decl);
136890
+ topMost.depth = depth;
136891
+ }
136892
+ else if (depth < topMost.depth) {
136893
+ topMost.declarationNames = [decl];
136894
+ topMost.depth = depth;
136895
+ }
136896
+ return topMost;
136897
+ }, { depth: Infinity, declarationNames: [] }).declarationNames;
136898
+ function getDepth(declaration) {
136899
+ var depth = 0;
136900
+ while (declaration) {
136901
+ declaration = ts.getContainerNode(declaration);
136902
+ depth++;
136903
+ }
136904
+ return depth;
136905
+ }
136906
+ }
136907
+ Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
136856
136908
  function someSignatureUsage(signature, sourceFiles, checker, cb) {
136857
136909
  if (!signature.name || !ts.isIdentifier(signature.name))
136858
136910
  return false;
@@ -138489,7 +138541,9 @@ var ts;
138489
138541
  (function (ts) {
138490
138542
  var GoToDefinition;
138491
138543
  (function (GoToDefinition) {
138492
- function getDefinitionAtPosition(program, sourceFile, position) {
138544
+ function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly) {
138545
+ var _a;
138546
+ var _b;
138493
138547
  var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
138494
138548
  var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
138495
138549
  if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
@@ -138512,33 +138566,63 @@ var ts;
138512
138566
  }
138513
138567
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
138514
138568
  var classDecl = node.parent.parent;
138515
- var symbol_1 = getSymbol(classDecl, typeChecker);
138569
+ var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
138516
138570
  var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
138517
138571
  var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
138518
138572
  var sourceFile_1 = node.getSourceFile();
138519
138573
  return ts.map(staticBlocks, function (staticBlock) {
138520
138574
  var pos = ts.moveRangePastModifiers(staticBlock).pos;
138521
138575
  pos = ts.skipTrivia(sourceFile_1.text, pos);
138522
- return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
138576
+ return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length });
138523
138577
  });
138524
138578
  }
138525
- var symbol = getSymbol(node, typeChecker);
138579
+ var _d = getSymbol(node, typeChecker), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
138580
+ var fallbackNode = node;
138581
+ if (searchOtherFilesOnly && failedAliasResolution) {
138582
+ // We couldn't resolve the specific import, try on the module specifier.
138583
+ var importDeclaration = ts.forEach(__spreadArray([node], (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, true), function (n) { return ts.findAncestor(n, ts.isAnyImportOrBareOrAccessedRequire); });
138584
+ var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
138585
+ if (moduleSpecifier) {
138586
+ (_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
138587
+ fallbackNode = moduleSpecifier;
138588
+ }
138589
+ }
138590
+ if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
138591
+ // We couldn't resolve the module specifier as an external module, but it could
138592
+ // be that module resolution succeeded but the target was not a module.
138593
+ var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
138594
+ if (ref) {
138595
+ return [{
138596
+ name: fallbackNode.text,
138597
+ fileName: ref.resolvedFileName,
138598
+ containerName: undefined,
138599
+ containerKind: undefined,
138600
+ kind: "script" /* scriptElement */,
138601
+ textSpan: ts.createTextSpan(0, 0),
138602
+ failedAliasResolution: failedAliasResolution,
138603
+ isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
138604
+ unverified: fallbackNode !== node,
138605
+ }];
138606
+ }
138607
+ }
138526
138608
  // Could not find a symbol e.g. node is string or number keyword,
138527
138609
  // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
138528
138610
  if (!symbol) {
138529
138611
  return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
138530
138612
  }
138613
+ if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
138614
+ return undefined;
138531
138615
  var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
138532
138616
  // Don't go to the component constructor definition for a JSX element, just go to the component definition.
138533
138617
  if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
138534
- var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
138618
+ var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
138535
138619
  // For a function, if this is the original function definition, return just sigInfo.
138536
138620
  // If this is the original constructor definition, parent is the class.
138537
138621
  if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
138538
138622
  return [sigInfo];
138539
138623
  }
138540
138624
  else {
138541
- var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
138625
+ var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
138542
138626
  // For a 'super()' call, put the signature first, else put the variable first.
138543
138627
  return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
138544
138628
  }
@@ -138550,7 +138634,7 @@ var ts;
138550
138634
  // assignment. This case and others are handled by the following code.
138551
138635
  if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) {
138552
138636
  var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
138553
- var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : ts.emptyArray;
138637
+ var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray;
138554
138638
  return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
138555
138639
  }
138556
138640
  // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
@@ -138573,7 +138657,7 @@ var ts;
138573
138657
  return prop && getDefinitionFromSymbol(typeChecker, prop, node);
138574
138658
  });
138575
138659
  }
138576
- return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
138660
+ return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
138577
138661
  }
138578
138662
  GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
138579
138663
  /**
@@ -138671,24 +138755,24 @@ var ts;
138671
138755
  return undefined;
138672
138756
  }
138673
138757
  if (ts.isImportMeta(node.parent) && node.parent.name === node) {
138674
- return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
138758
+ return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
138675
138759
  }
138676
- var symbol = getSymbol(node, typeChecker);
138760
+ var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
138677
138761
  if (!symbol)
138678
138762
  return undefined;
138679
138763
  var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
138680
138764
  var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
138681
- var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
138765
+ var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
138682
138766
  // If a function returns 'void' or some other type with no definition, just return the function definition.
138683
- var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
138767
+ var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
138684
138768
  return typeDefinitions.length ? typeDefinitions
138685
- : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
138769
+ : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
138686
138770
  : undefined;
138687
138771
  }
138688
138772
  GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
138689
- function definitionFromType(type, checker, node) {
138773
+ function definitionFromType(type, checker, node, failedAliasResolution) {
138690
138774
  return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
138691
- return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
138775
+ return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
138692
138776
  });
138693
138777
  }
138694
138778
  function tryGetReturnTypeOfFunction(symbol, type, checker) {
@@ -138730,13 +138814,17 @@ var ts;
138730
138814
  // get the aliased symbol instead. This allows for goto def on an import e.g.
138731
138815
  // import {A, B} from "mod";
138732
138816
  // to jump to the implementation directly.
138817
+ var failedAliasResolution = false;
138733
138818
  if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
138734
138819
  var aliased = checker.getAliasedSymbol(symbol);
138735
138820
  if (aliased.declarations) {
138736
- return aliased;
138821
+ return { symbol: aliased };
138822
+ }
138823
+ else {
138824
+ failedAliasResolution = true;
138737
138825
  }
138738
138826
  }
138739
- return symbol;
138827
+ return { symbol: symbol, failedAliasResolution: failedAliasResolution };
138740
138828
  }
138741
138829
  // Go to the original declaration for cases:
138742
138830
  //
@@ -138750,26 +138838,45 @@ var ts;
138750
138838
  if (node.parent === declaration) {
138751
138839
  return true;
138752
138840
  }
138753
- switch (declaration.kind) {
138754
- case 267 /* ImportClause */:
138755
- case 265 /* ImportEqualsDeclaration */:
138756
- return true;
138757
- case 270 /* ImportSpecifier */:
138758
- return declaration.parent.kind === 269 /* NamedImports */;
138759
- case 203 /* BindingElement */:
138760
- case 254 /* VariableDeclaration */:
138761
- return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
138762
- default:
138763
- return false;
138841
+ if (declaration.kind === 268 /* NamespaceImport */) {
138842
+ return false;
138764
138843
  }
138844
+ return true;
138765
138845
  }
138766
- function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) {
138767
- // There are cases when you extend a function by adding properties to it afterwards,
138768
- // we want to strip those extra properties.
138769
- // For deduping purposes, we also want to exclude any declarationNodes if provided.
138770
- var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); })
138771
- || undefined;
138772
- return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
138846
+ /**
138847
+ * ```ts
138848
+ * function f() {}
138849
+ * f.foo = 0;
138850
+ * ```
138851
+ *
138852
+ * Here, `f` has two declarations: the function declaration, and the identifier in the next line.
138853
+ * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
138854
+ * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
138855
+ * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
138856
+ * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
138857
+ * declaration looks like an assignment, that declaration is in no sense a definition for `f`.
138858
+ * But that information is totally lost during binding and/or symbol merging, so we need to do
138859
+ * our best to reconstruct it or use other heuristics. This function (and the logic around its
138860
+ * calling) covers our tests but feels like a hack, and it would be great if someone could come
138861
+ * up with a more precise definition of what counts as a definition.
138862
+ */
138863
+ function isExpandoDeclaration(node) {
138864
+ if (!ts.isAssignmentDeclaration(node))
138865
+ return false;
138866
+ var containingAssignment = ts.findAncestor(node, function (p) {
138867
+ if (ts.isAssignmentExpression(p))
138868
+ return true;
138869
+ if (!ts.isAssignmentDeclaration(p))
138870
+ return "quit";
138871
+ return false;
138872
+ });
138873
+ return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
138874
+ }
138875
+ function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
138876
+ var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
138877
+ var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
138878
+ var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
138879
+ return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); });
138773
138880
  function getConstructSignatureDefinition() {
138774
138881
  // Applicable only if we are in a new expression, or we are on a constructor declaration
138775
138882
  // and in either case the symbol has a construct signature definition, i.e. class
@@ -138793,26 +138900,27 @@ var ts;
138793
138900
  return declarations.length
138794
138901
  ? declarationsWithBody.length !== 0
138795
138902
  ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
138796
- : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
138903
+ : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)]
138797
138904
  : undefined;
138798
138905
  }
138799
138906
  }
138800
138907
  /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
138801
- function createDefinitionInfo(declaration, checker, symbol, node) {
138908
+ function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) {
138802
138909
  var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
138803
138910
  var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
138804
138911
  var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
138805
- return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
138912
+ return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution);
138806
138913
  }
138914
+ GoToDefinition.createDefinitionInfo = createDefinitionInfo;
138807
138915
  /** Creates a DefinitionInfo directly from the name of a declaration. */
138808
- function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
138916
+ function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) {
138809
138917
  var sourceFile = declaration.getSourceFile();
138810
138918
  if (!textSpan) {
138811
138919
  var name = ts.getNameOfDeclaration(declaration) || declaration;
138812
138920
  textSpan = ts.createTextSpanFromNode(name, sourceFile);
138813
138921
  }
138814
138922
  return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
138815
- containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
138923
+ containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution });
138816
138924
  }
138817
138925
  function isDefinitionVisible(checker, declaration) {
138818
138926
  if (checker.isDeclarationVisible(declaration))
@@ -138845,8 +138953,8 @@ var ts;
138845
138953
  return false;
138846
138954
  }
138847
138955
  }
138848
- function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
138849
- return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
138956
+ function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
138957
+ return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution);
138850
138958
  }
138851
138959
  function findReferenceInPosition(refs, pos) {
138852
138960
  return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
@@ -151961,9 +152069,10 @@ var ts;
151961
152069
  // 2. add "member3" to the second import statement's import list
151962
152070
  // and it is up to the user to decide which one fits best.
151963
152071
  return ts.firstDefined(existingImports, function (_a) {
152072
+ var _b;
151964
152073
  var declaration = _a.declaration;
151965
152074
  var namespacePrefix = getNamespaceLikeImportText(declaration);
151966
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
152075
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
151967
152076
  if (namespacePrefix && moduleSpecifier) {
151968
152077
  var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
151969
152078
  if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
@@ -152139,8 +152248,9 @@ var ts;
152139
152248
  return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
152140
152249
  }
152141
152250
  function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
152251
+ var _b;
152142
152252
  var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
152143
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
152253
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
152144
152254
  if (moduleSpecifier) {
152145
152255
  var addAsTypeOnly = useRequire
152146
152256
  ? 4 /* NotAllowed */
@@ -156498,7 +156608,6 @@ var ts;
156498
156608
  var checker = program.getTypeChecker();
156499
156609
  var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
156500
156610
  var flags = 1 /* NoTruncation */
156501
- | 1073741824 /* NoUndefinedOptionalParameterType */
156502
156611
  | 256 /* SuppressAnyReturnType */
156503
156612
  | 524288 /* AllowEmptyTuple */
156504
156613
  | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
@@ -164079,9 +164188,9 @@ var ts;
164079
164188
  }
164080
164189
  }
164081
164190
  /// Goto definition
164082
- function getDefinitionAtPosition(fileName, position) {
164191
+ function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly) {
164083
164192
  synchronizeHostData();
164084
- return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
164193
+ return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly);
164085
164194
  }
164086
164195
  function getDefinitionAndBoundSpan(fileName, position) {
164087
164196
  synchronizeHostData();
@@ -167039,6 +167148,11 @@ var ts;
167039
167148
  return "/dev/null/autoImportProviderProject" + counter + "*";
167040
167149
  }
167041
167150
  server.makeAutoImportProviderProjectName = makeAutoImportProviderProjectName;
167151
+ /*@internal*/
167152
+ function makeAuxiliaryProjectName(counter) {
167153
+ return "/dev/null/auxiliaryProject" + counter + "*";
167154
+ }
167155
+ server.makeAuxiliaryProjectName = makeAuxiliaryProjectName;
167042
167156
  function createSortedArray() {
167043
167157
  return []; // TODO: GH#19873
167044
167158
  }
@@ -167252,6 +167366,7 @@ var ts;
167252
167366
  CommandTypes["SignatureHelp"] = "signatureHelp";
167253
167367
  /* @internal */
167254
167368
  CommandTypes["SignatureHelpFull"] = "signatureHelp-full";
167369
+ CommandTypes["FindSourceDefinition"] = "findSourceDefinition";
167255
167370
  CommandTypes["Status"] = "status";
167256
167371
  CommandTypes["TypeDefinition"] = "typeDefinition";
167257
167372
  CommandTypes["ProjectInfo"] = "projectInfo";
@@ -167831,7 +167946,7 @@ var ts;
167831
167946
  case 0:
167832
167947
  return server.Errors.ThrowNoProject();
167833
167948
  case 1:
167834
- return ensureNotAutoImportProvider(this.containingProjects[0]);
167949
+ return ensurePrimaryProjectKind(this.containingProjects[0]);
167835
167950
  default:
167836
167951
  // If this file belongs to multiple projects, below is the order in which default project is used
167837
167952
  // - for open script info, its default configured project during opening is default if info is part of it
@@ -167869,7 +167984,7 @@ var ts;
167869
167984
  firstInferredProject = project;
167870
167985
  }
167871
167986
  }
167872
- return ensureNotAutoImportProvider(defaultConfiguredProject ||
167987
+ return ensurePrimaryProjectKind(defaultConfiguredProject ||
167873
167988
  firstNonSourceOfProjectReferenceRedirect ||
167874
167989
  firstConfiguredProject ||
167875
167990
  firstExternalProject ||
@@ -167945,8 +168060,8 @@ var ts;
167945
168060
  return !ts.forEach(this.containingProjects, function (p) { return !p.isOrphan(); });
167946
168061
  };
167947
168062
  /*@internal*/
167948
- ScriptInfo.prototype.isContainedByAutoImportProvider = function () {
167949
- return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider; });
168063
+ ScriptInfo.prototype.isContainedByBackgroundProject = function () {
168064
+ return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider || p.projectKind === server.ProjectKind.Auxiliary; });
167950
168065
  };
167951
168066
  /**
167952
168067
  * @param line 1 based index
@@ -167980,8 +168095,13 @@ var ts;
167980
168095
  return ScriptInfo;
167981
168096
  }());
167982
168097
  server.ScriptInfo = ScriptInfo;
167983
- function ensureNotAutoImportProvider(project) {
167984
- if (!project || project.projectKind === server.ProjectKind.AutoImportProvider) {
168098
+ /**
168099
+ * Throws an error if `project` is an AutoImportProvider or AuxiliaryProject,
168100
+ * which are used in the background by other Projects and should never be
168101
+ * reported as the default project for a ScriptInfo.
168102
+ */
168103
+ function ensurePrimaryProjectKind(project) {
168104
+ if (!project || project.projectKind === server.ProjectKind.AutoImportProvider || project.projectKind === server.ProjectKind.Auxiliary) {
167985
168105
  return server.Errors.ThrowNoProject();
167986
168106
  }
167987
168107
  return project;
@@ -168121,6 +168241,7 @@ var ts;
168121
168241
  ProjectKind[ProjectKind["Configured"] = 1] = "Configured";
168122
168242
  ProjectKind[ProjectKind["External"] = 2] = "External";
168123
168243
  ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider";
168244
+ ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary";
168124
168245
  })(ProjectKind = server.ProjectKind || (server.ProjectKind = {}));
168125
168246
  /* @internal */
168126
168247
  function countEachFileTypes(infos, includeSizes) {
@@ -168146,7 +168267,7 @@ var ts;
168146
168267
  result.jsxSize += fileSize;
168147
168268
  break;
168148
168269
  case 3 /* TS */:
168149
- if (ts.fileExtensionIs(info.fileName, ".d.ts" /* Dts */)) {
168270
+ if (ts.isDeclarationFileName(info.fileName)) {
168150
168271
  result.dts += 1;
168151
168272
  result.dtsSize += fileSize;
168152
168273
  }
@@ -168184,7 +168305,7 @@ var ts;
168184
168305
  server.allFilesAreJsOrDts = allFilesAreJsOrDts;
168185
168306
  /* @internal */
168186
168307
  function hasNoTypeScriptSource(fileNames) {
168187
- return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) || ts.fileExtensionIs(fileName, ".tsx" /* Tsx */); });
168308
+ return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.isDeclarationFileName(fileName)) || ts.fileExtensionIs(fileName, ".tsx" /* Tsx */); });
168188
168309
  }
168189
168310
  server.hasNoTypeScriptSource = hasNoTypeScriptSource;
168190
168311
  function isGeneratedFileWatcher(watch) {
@@ -168588,7 +168709,7 @@ var ts;
168588
168709
  }
168589
168710
  // Update the signature
168590
168711
  if (this.builderState && ts.getEmitDeclarations(this.compilerOptions)) {
168591
- var dtsFiles = outputFiles.filter(function (f) { return ts.fileExtensionIs(f.name, ".d.ts" /* Dts */); });
168712
+ var dtsFiles = outputFiles.filter(function (f) { return ts.isDeclarationFileName(f.name); });
168592
168713
  if (dtsFiles.length === 1) {
168593
168714
  var sourceFile = this.program.getSourceFile(scriptInfo.fileName);
168594
168715
  var signature = this.projectService.host.createHash ?
@@ -168707,6 +168828,10 @@ var ts;
168707
168828
  this.autoImportProviderHost.close();
168708
168829
  }
168709
168830
  this.autoImportProviderHost = undefined;
168831
+ if (this.noDtsResolutionProject) {
168832
+ this.noDtsResolutionProject.close();
168833
+ }
168834
+ this.noDtsResolutionProject = undefined;
168710
168835
  // signal language service to release source files acquired from document registry
168711
168836
  this.languageService.dispose();
168712
168837
  this.languageService = undefined;
@@ -169229,11 +169354,13 @@ var ts;
169229
169354
  }
169230
169355
  };
169231
169356
  Project.prototype.setCompilerOptions = function (compilerOptions) {
169357
+ var _a;
169232
169358
  if (compilerOptions) {
169233
169359
  compilerOptions.allowNonTsExtensions = true;
169234
169360
  var oldOptions = this.compilerOptions;
169235
169361
  this.compilerOptions = compilerOptions;
169236
169362
  this.setInternalCompilerOptionsForEmittingJsFiles();
169363
+ (_a = this.noDtsResolutionProject) === null || _a === void 0 ? void 0 : _a.setCompilerOptions(this.getCompilerOptionsForNoDtsResolutionProject());
169237
169364
  if (ts.changesAffectModuleResolution(oldOptions, compilerOptions)) {
169238
169365
  // reset cached unresolved imports if changes in compiler options affected module resolution
169239
169366
  this.cachedUnresolvedImportsPerFile.clear();
@@ -169573,6 +169700,31 @@ var ts;
169573
169700
  Project.prototype.getIncompleteCompletionsCache = function () {
169574
169701
  return this.projectService.getIncompleteCompletionsCache();
169575
169702
  };
169703
+ /*@internal*/
169704
+ Project.prototype.getNoDtsResolutionProject = function (rootFileNames) {
169705
+ var _this = this;
169706
+ ts.Debug.assert(this.projectService.serverMode === ts.LanguageServiceMode.Semantic);
169707
+ if (!this.noDtsResolutionProject) {
169708
+ this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject());
169709
+ }
169710
+ ts.enumerateInsertsAndDeletes(rootFileNames.map(server.toNormalizedPath), this.noDtsResolutionProject.getRootFiles(), ts.getStringComparer(!this.useCaseSensitiveFileNames()), function (pathToAdd) {
169711
+ var info = _this.projectService.getOrCreateScriptInfoNotOpenedByClient(pathToAdd, _this.currentDirectory, _this.noDtsResolutionProject.directoryStructureHost);
169712
+ if (info) {
169713
+ _this.noDtsResolutionProject.addRoot(info, pathToAdd);
169714
+ }
169715
+ }, function (pathToRemove) {
169716
+ // It may be preferable to remove roots only once project grows to a certain size?
169717
+ var info = _this.noDtsResolutionProject.getScriptInfo(pathToRemove);
169718
+ if (info) {
169719
+ _this.noDtsResolutionProject.removeRoot(info);
169720
+ }
169721
+ });
169722
+ return this.noDtsResolutionProject;
169723
+ };
169724
+ /*@internal*/
169725
+ Project.prototype.getCompilerOptionsForNoDtsResolutionProject = function () {
169726
+ return __assign(__assign({}, this.getCompilerOptions()), { noDtsResolution: true, allowJs: true, maxNodeModuleJsDepth: 3, diagnostics: false, skipLibCheck: true, sourceMap: false, types: ts.emptyArray, lib: ts.emptyArray, noLib: true });
169727
+ };
169576
169728
  return Project;
169577
169729
  }());
169578
169730
  server.Project = Project;
@@ -169688,6 +169840,26 @@ var ts;
169688
169840
  return InferredProject;
169689
169841
  }(Project));
169690
169842
  server.InferredProject = InferredProject;
169843
+ var AuxiliaryProject = /** @class */ (function (_super) {
169844
+ __extends(AuxiliaryProject, _super);
169845
+ function AuxiliaryProject(projectService, documentRegistry, compilerOptions) {
169846
+ return _super.call(this, projectService.newAuxiliaryProjectName(), ProjectKind.Auxiliary, projectService, documentRegistry,
169847
+ /*hasExplicitListOfFiles*/ false,
169848
+ /*lastFileExceededProgramSize*/ undefined, compilerOptions,
169849
+ /*compileOnSaveEnabled*/ false,
169850
+ /*watchOptions*/ undefined, projectService.host,
169851
+ /*currentDirectory*/ undefined) || this;
169852
+ }
169853
+ AuxiliaryProject.prototype.isOrphan = function () {
169854
+ return true;
169855
+ };
169856
+ /*@internal*/
169857
+ AuxiliaryProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () {
169858
+ // Invalidation will happen on-demand as part of updateGraph
169859
+ return;
169860
+ };
169861
+ return AuxiliaryProject;
169862
+ }(Project));
169691
169863
  var AutoImportProviderProject = /** @class */ (function (_super) {
169692
169864
  __extends(AutoImportProviderProject, _super);
169693
169865
  /*@internal*/
@@ -169839,6 +170011,11 @@ var ts;
169839
170011
  }
169840
170012
  return hasSameSetOfFiles;
169841
170013
  };
170014
+ /*@internal*/
170015
+ AutoImportProviderProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () {
170016
+ // Invalidation will happen on-demand as part of updateGraph
170017
+ return;
170018
+ };
169842
170019
  AutoImportProviderProject.prototype.hasRoots = function () {
169843
170020
  var _a;
169844
170021
  return !!((_a = this.rootFileNames) === null || _a === void 0 ? void 0 : _a.length);
@@ -170524,6 +170701,8 @@ var ts;
170524
170701
  this.newInferredProjectName = createProjectNameFactoryWithCounter(server.makeInferredProjectName);
170525
170702
  /*@internal*/
170526
170703
  this.newAutoImportProviderProjectName = createProjectNameFactoryWithCounter(server.makeAutoImportProviderProjectName);
170704
+ /*@internal*/
170705
+ this.newAuxiliaryProjectName = createProjectNameFactoryWithCounter(server.makeAuxiliaryProjectName);
170527
170706
  /**
170528
170707
  * Open files: with value being project root path, and key being Path of the file that is open
170529
170708
  */
@@ -170727,13 +170906,15 @@ var ts;
170727
170906
  ProjectService.prototype.delayUpdateProjectGraph = function (project) {
170728
170907
  var _this = this;
170729
170908
  project.markAsDirty();
170730
- var projectName = project.getProjectName();
170731
- this.pendingProjectUpdates.set(projectName, project);
170732
- this.throttledOperations.schedule(projectName, /*delay*/ 250, function () {
170733
- if (_this.pendingProjectUpdates.delete(projectName)) {
170734
- updateProjectIfDirty(project);
170735
- }
170736
- });
170909
+ if (project.projectKind !== server.ProjectKind.AutoImportProvider && project.projectKind !== server.ProjectKind.Auxiliary) {
170910
+ var projectName_1 = project.getProjectName();
170911
+ this.pendingProjectUpdates.set(projectName_1, project);
170912
+ this.throttledOperations.schedule(projectName_1, /*delay*/ 250, function () {
170913
+ if (_this.pendingProjectUpdates.delete(projectName_1)) {
170914
+ updateProjectIfDirty(project);
170915
+ }
170916
+ });
170917
+ }
170737
170918
  };
170738
170919
  /*@internal*/
170739
170920
  ProjectService.prototype.hasPendingProjectUpdate = function (project) {
@@ -173014,7 +173195,7 @@ var ts;
173014
173195
  var toRemoveScriptInfos = new ts.Map(this.filenameToScriptInfo);
173015
173196
  this.filenameToScriptInfo.forEach(function (info) {
173016
173197
  // If script info is open or orphan, retain it and its dependencies
173017
- if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByAutoImportProvider()) {
173198
+ if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByBackgroundProject()) {
173018
173199
  // Otherwise if there is any source info that is alive, this alive too
173019
173200
  if (!info.sourceMapFilePath)
173020
173201
  return;
@@ -174310,6 +174491,9 @@ var ts;
174310
174491
  _a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) {
174311
174492
  return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
174312
174493
  },
174494
+ _a[server.CommandNames.FindSourceDefinition] = function (request) {
174495
+ return _this.requiredResponse(_this.findSourceDefinition(request.arguments));
174496
+ },
174313
174497
  _a[server.CommandNames.EmitOutput] = function (request) {
174314
174498
  return _this.requiredResponse(_this.getEmitOutput(request.arguments));
174315
174499
  },
@@ -175051,7 +175235,7 @@ var ts;
175051
175235
  Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
175052
175236
  return definitions.map(function (info) {
175053
175237
  var newDocumentSpan = getMappedDocumentSpan(info, project);
175054
- return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified });
175238
+ return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name, failedAliasResolution: info.failedAliasResolution }), info.unverified && { unverified: info.unverified });
175055
175239
  });
175056
175240
  };
175057
175241
  Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) {
@@ -175078,6 +175262,152 @@ var ts;
175078
175262
  textSpan: textSpan,
175079
175263
  };
175080
175264
  };
175265
+ Session.prototype.findSourceDefinition = function (args) {
175266
+ var _a;
175267
+ var _b = this.getFileAndProject(args), file = _b.file, project = _b.project;
175268
+ var position = this.getPositionInFile(args, file);
175269
+ var unmappedDefinitions = project.getLanguageService().getDefinitionAtPosition(file, position);
175270
+ var definitions = this.mapDefinitionInfoLocations(unmappedDefinitions || server.emptyArray, project).slice();
175271
+ var needsJsResolution = this.projectService.serverMode === ts.LanguageServiceMode.Semantic && (!ts.some(definitions, function (d) { return server.toNormalizedPath(d.fileName) !== file && !d.isAmbient; }) ||
175272
+ ts.some(definitions, function (d) { return !!d.failedAliasResolution; }));
175273
+ if (needsJsResolution) {
175274
+ var definitionSet_1 = ts.createSet(function (d) { return d.textSpan.start; }, ts.documentSpansEqual);
175275
+ definitions === null || definitions === void 0 ? void 0 : definitions.forEach(function (d) { return definitionSet_1.add(d); });
175276
+ var noDtsProject = project.getNoDtsResolutionProject([file]);
175277
+ var ls = noDtsProject.getLanguageService();
175278
+ var jsDefinitions = (_a = ls.getDefinitionAtPosition(file, position, /*searchOtherFilesOnly*/ true)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file; });
175279
+ if (ts.some(jsDefinitions)) {
175280
+ for (var _i = 0, jsDefinitions_1 = jsDefinitions; _i < jsDefinitions_1.length; _i++) {
175281
+ var jsDefinition = jsDefinitions_1[_i];
175282
+ if (jsDefinition.unverified) {
175283
+ var refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram(), ls.getProgram());
175284
+ if (ts.some(refined)) {
175285
+ for (var _c = 0, refined_1 = refined; _c < refined_1.length; _c++) {
175286
+ var def = refined_1[_c];
175287
+ definitionSet_1.add(def);
175288
+ }
175289
+ continue;
175290
+ }
175291
+ }
175292
+ definitionSet_1.add(jsDefinition);
175293
+ }
175294
+ }
175295
+ else {
175296
+ var ambientCandidates = definitions.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; });
175297
+ for (var _d = 0, _e = ts.some(ambientCandidates) ? ambientCandidates : getAmbientCandidatesByClimbingAccessChain(); _d < _e.length; _d++) {
175298
+ var candidate = _e[_d];
175299
+ var fileNameToSearch = findImplementationFileFromDtsFileName(candidate.fileName, file, noDtsProject);
175300
+ if (!fileNameToSearch || !ensureRoot(noDtsProject, fileNameToSearch)) {
175301
+ continue;
175302
+ }
175303
+ var noDtsProgram = ls.getProgram();
175304
+ var fileToSearch = ts.Debug.checkDefined(noDtsProgram.getSourceFile(fileNameToSearch));
175305
+ for (var _f = 0, _g = searchForDeclaration(candidate.name, fileToSearch, noDtsProgram); _f < _g.length; _f++) {
175306
+ var match = _g[_f];
175307
+ definitionSet_1.add(match);
175308
+ }
175309
+ }
175310
+ }
175311
+ definitions = ts.arrayFrom(definitionSet_1.values());
175312
+ }
175313
+ definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; });
175314
+ return this.mapDefinitionInfo(definitions, project);
175315
+ function findImplementationFileFromDtsFileName(fileName, resolveFromFile, auxiliaryProject) {
175316
+ var _a;
175317
+ var nodeModulesPathParts = ts.getNodeModulePathParts(fileName);
175318
+ if (nodeModulesPathParts && fileName.lastIndexOf(ts.nodeModulesPathPart) === nodeModulesPathParts.topLevelNodeModulesIndex) {
175319
+ // Second check ensures the fileName only contains one `/node_modules/`. If there's more than one I give up.
175320
+ var packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex);
175321
+ var packageJsonCache = (_a = project.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache();
175322
+ var compilerOptions = project.getCompilationSettings();
175323
+ var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions);
175324
+ if (!packageJson)
175325
+ return undefined;
175326
+ // Use fake options instead of actual compiler options to avoid following export map if the project uses node12 or nodenext -
175327
+ // Mapping from an export map entry across packages is out of scope for now. Returned entrypoints will only be what can be
175328
+ // resolved from the package root under --moduleResolution node
175329
+ var entrypoints = ts.getEntrypointsFromPackageJsonInfo(packageJson, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, project, project.getModuleResolutionCache());
175330
+ // This substring is correct only because we checked for a single `/node_modules/` at the top.
175331
+ var packageNamePathPart = fileName.substring(nodeModulesPathParts.topLevelPackageNameIndex + 1, nodeModulesPathParts.packageRootIndex);
175332
+ var packageName = ts.getPackageNameFromTypesPackageName(ts.unmangleScopedPackageName(packageNamePathPart));
175333
+ var path_1 = project.toPath(fileName);
175334
+ if (entrypoints && ts.some(entrypoints, function (e) { return project.toPath(e) === path_1; })) {
175335
+ // This file was the main entrypoint of a package. Try to resolve that same package name with
175336
+ // the auxiliary project that only resolves to implementation files.
175337
+ var implementationResolution = auxiliaryProject.resolveModuleNames([packageName], resolveFromFile)[0];
175338
+ return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
175339
+ }
175340
+ else {
175341
+ // It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package.
175342
+ var pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1);
175343
+ var specifier = packageName + "/" + ts.removeFileExtension(pathToFileInPackage);
175344
+ var implementationResolution = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile)[0];
175345
+ return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
175346
+ }
175347
+ }
175348
+ // We're not in node_modules, and we only get to this function if non-dts module resolution failed.
175349
+ // I'm not sure what else I can do here that isn't already covered by that module resolution.
175350
+ return undefined;
175351
+ }
175352
+ // In 'foo.bar./**/baz', if we got not results on 'baz', see if we can get an ambient definition
175353
+ // for 'bar' or 'foo' (in that order) so we can search for declarations of 'baz' later.
175354
+ function getAmbientCandidatesByClimbingAccessChain() {
175355
+ var ls = project.getLanguageService();
175356
+ var program = ls.getProgram();
175357
+ var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
175358
+ if ((ts.isStringLiteralLike(initialNode) || ts.isIdentifier(initialNode)) && ts.isAccessExpression(initialNode.parent)) {
175359
+ return ts.forEachNameInAccessChainWalkingLeft(initialNode, function (nameInChain) {
175360
+ var _a;
175361
+ if (nameInChain === initialNode)
175362
+ return undefined;
175363
+ var candidates = (_a = ls.getDefinitionAtPosition(file, nameInChain.getStart(), /*searchOtherFilesOnly*/ true)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; }).map(function (d) { return ({
175364
+ fileName: d.fileName,
175365
+ name: ts.getTextOfIdentifierOrLiteral(initialNode)
175366
+ }); });
175367
+ if (ts.some(candidates)) {
175368
+ return candidates;
175369
+ }
175370
+ }) || server.emptyArray;
175371
+ }
175372
+ return server.emptyArray;
175373
+ }
175374
+ function tryRefineDefinition(definition, program, noDtsProgram) {
175375
+ var _a;
175376
+ var fileToSearch = noDtsProgram.getSourceFile(definition.fileName);
175377
+ if (!fileToSearch) {
175378
+ return undefined;
175379
+ }
175380
+ var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
175381
+ var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode);
175382
+ var importSpecifier = symbol && ts.getDeclarationOfKind(symbol, 270 /* ImportSpecifier */);
175383
+ if (!importSpecifier)
175384
+ return undefined;
175385
+ var nameToSearch = ((_a = importSpecifier.propertyName) === null || _a === void 0 ? void 0 : _a.text) || importSpecifier.name.text;
175386
+ return searchForDeclaration(nameToSearch, fileToSearch, noDtsProgram);
175387
+ }
175388
+ function searchForDeclaration(declarationName, fileToSearch, noDtsProgram) {
175389
+ var matches = ts.FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch);
175390
+ return ts.mapDefined(matches, function (match) {
175391
+ var symbol = noDtsProgram.getTypeChecker().getSymbolAtLocation(match);
175392
+ var decl = ts.getDeclarationFromName(match);
175393
+ if (symbol && decl) {
175394
+ // I think the last argument to this is supposed to be the start node, but it doesn't seem important.
175395
+ // Callers internal to GoToDefinition already get confused about this.
175396
+ return ts.GoToDefinition.createDefinitionInfo(decl, noDtsProgram.getTypeChecker(), symbol, decl, /*unverified*/ true);
175397
+ }
175398
+ });
175399
+ }
175400
+ function ensureRoot(project, fileName) {
175401
+ var info = project.getScriptInfo(fileName);
175402
+ if (!info)
175403
+ return false;
175404
+ if (!project.containsScriptInfo(info)) {
175405
+ project.addRoot(info);
175406
+ project.updateGraph();
175407
+ }
175408
+ return true;
175409
+ }
175410
+ };
175081
175411
  Session.prototype.getEmitOutput = function (args) {
175082
175412
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
175083
175413
  if (!project.shouldEmitFile(project.getScriptInfo(file))) {
@@ -175641,7 +175971,7 @@ var ts;
175641
175971
  return undefined;
175642
175972
  }
175643
175973
  var compilationSettings = project.getCompilationSettings();
175644
- if (!!compilationSettings.noEmit || ts.fileExtensionIs(info.fileName, ".d.ts" /* Dts */) && !dtsChangeCanAffectEmit(compilationSettings)) {
175974
+ if (!!compilationSettings.noEmit || ts.isDeclarationFileName(info.fileName) && !dtsChangeCanAffectEmit(compilationSettings)) {
175645
175975
  // avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled
175646
175976
  return undefined;
175647
175977
  }
@@ -176121,7 +176451,7 @@ var ts;
176121
176451
  else {
176122
176452
  var info = this.projectService.getScriptInfo(fileNameInProject); // TODO: GH#18217
176123
176453
  if (!info.isScriptOpen()) {
176124
- if (ts.fileExtensionIs(fileNameInProject, ".d.ts" /* Dts */)) {
176454
+ if (ts.isDeclarationFileName(fileNameInProject)) {
176125
176455
  veryLowPriorityFiles.push(fileNameInProject);
176126
176456
  }
176127
176457
  else {