typescript 4.7.0-dev.20220408 → 4.7.0-dev.20220415

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220408";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220415";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -4854,7 +4854,6 @@ var ts;
4854
4854
  NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
4855
4855
  NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
4856
4856
  NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
4857
- NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType";
4858
4857
  // Error handling
4859
4858
  NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
4860
4859
  NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
@@ -15160,6 +15159,10 @@ var ts;
15160
15159
  }
15161
15160
  }
15162
15161
  ts.isAnyImportSyntax = isAnyImportSyntax;
15162
+ function isAnyImportOrBareOrAccessedRequire(node) {
15163
+ return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
15164
+ }
15165
+ ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
15163
15166
  function isLateVisibilityPaintedStatement(node) {
15164
15167
  switch (node.kind) {
15165
15168
  case 266 /* ImportDeclaration */:
@@ -16520,17 +16523,13 @@ var ts;
16520
16523
  if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
16521
16524
  return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
16522
16525
  }
16523
- if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
16526
+ if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) &&
16524
16527
  (initializer.expression.kind === 108 /* ThisKeyword */ ||
16525
16528
  ts.isIdentifier(initializer.expression) &&
16526
16529
  (initializer.expression.escapedText === "window" ||
16527
16530
  initializer.expression.escapedText === "self" ||
16528
16531
  initializer.expression.escapedText === "global"))) {
16529
- var nameOrArgument = getNameOrArgument(initializer);
16530
- if (ts.isPrivateIdentifier(nameOrArgument)) {
16531
- ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
16532
- }
16533
- return isSameEntityName(name, nameOrArgument);
16532
+ return isSameEntityName(name, getNameOrArgument(initializer));
16534
16533
  }
16535
16534
  if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
16536
16535
  return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
@@ -16738,14 +16737,14 @@ var ts;
16738
16737
  }
16739
16738
  ts.isFunctionSymbol = isFunctionSymbol;
16740
16739
  function tryGetModuleSpecifierFromDeclaration(node) {
16741
- var _a, _b, _c;
16740
+ var _a, _b;
16742
16741
  switch (node.kind) {
16743
16742
  case 254 /* VariableDeclaration */:
16744
- return node.initializer.arguments[0].text;
16743
+ return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
16745
16744
  case 266 /* ImportDeclaration */:
16746
- return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text;
16745
+ return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
16747
16746
  case 265 /* ImportEqualsDeclaration */:
16748
- 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;
16747
+ return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
16749
16748
  default:
16750
16749
  ts.Debug.assertNever(node);
16751
16750
  }
@@ -17260,7 +17259,10 @@ var ts;
17260
17259
  return parent.propertyName === node;
17261
17260
  case 275 /* ExportSpecifier */:
17262
17261
  case 285 /* JsxAttribute */:
17263
- // Any name in an export specifier or JSX Attribute
17262
+ case 279 /* JsxSelfClosingElement */:
17263
+ case 280 /* JsxOpeningElement */:
17264
+ case 281 /* JsxClosingElement */:
17265
+ // Any name in an export specifier or JSX Attribute or Jsx Element
17264
17266
  return true;
17265
17267
  }
17266
17268
  return false;
@@ -17276,21 +17278,28 @@ var ts;
17276
17278
  // export = <EntityNameExpression>
17277
17279
  // export default <EntityNameExpression>
17278
17280
  // module.exports = <EntityNameExpression>
17279
- // {<Identifier>}
17280
- // {name: <EntityNameExpression>}
17281
+ // module.exports.x = <EntityNameExpression>
17282
+ // const x = require("...")
17283
+ // const { x } = require("...")
17284
+ // const x = require("...").y
17285
+ // const { x } = require("...").y
17281
17286
  function isAliasSymbolDeclaration(node) {
17282
- return node.kind === 265 /* ImportEqualsDeclaration */ ||
17287
+ if (node.kind === 265 /* ImportEqualsDeclaration */ ||
17283
17288
  node.kind === 264 /* NamespaceExportDeclaration */ ||
17284
17289
  node.kind === 267 /* ImportClause */ && !!node.name ||
17285
17290
  node.kind === 268 /* NamespaceImport */ ||
17286
17291
  node.kind === 274 /* NamespaceExport */ ||
17287
17292
  node.kind === 270 /* ImportSpecifier */ ||
17288
17293
  node.kind === 275 /* ExportSpecifier */ ||
17289
- node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node) ||
17290
- ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17291
- ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) ||
17292
- node.kind === 297 /* ShorthandPropertyAssignment */ ||
17293
- node.kind === 296 /* PropertyAssignment */ && isAliasableExpression(node.initializer);
17294
+ node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
17295
+ return true;
17296
+ }
17297
+ return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
17298
+ ts.isPropertyAccessExpression(node)
17299
+ && ts.isBinaryExpression(node.parent)
17300
+ && node.parent.left === node
17301
+ && node.parent.operatorToken.kind === 63 /* EqualsToken */
17302
+ && isAliasableExpression(node.parent.right));
17294
17303
  }
17295
17304
  ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
17296
17305
  function getAliasDeclarationFromName(node) {
@@ -17301,6 +17310,7 @@ var ts;
17301
17310
  case 275 /* ExportSpecifier */:
17302
17311
  case 271 /* ExportAssignment */:
17303
17312
  case 265 /* ImportEqualsDeclaration */:
17313
+ case 274 /* NamespaceExport */:
17304
17314
  return node.parent;
17305
17315
  case 161 /* QualifiedName */:
17306
17316
  do {
@@ -19127,6 +19137,11 @@ var ts;
19127
19137
  (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node);
19128
19138
  }
19129
19139
  ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
19140
+ function isRightSideOfAccessExpression(node) {
19141
+ return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
19142
+ || ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node;
19143
+ }
19144
+ ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression;
19130
19145
  function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
19131
19146
  return ts.isQualifiedName(node.parent) && node.parent.right === node
19132
19147
  || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
@@ -19778,6 +19793,41 @@ var ts;
19778
19793
  return expr;
19779
19794
  }
19780
19795
  ts.getLeftmostAccessExpression = getLeftmostAccessExpression;
19796
+ function forEachNameInAccessChainWalkingLeft(name, action) {
19797
+ if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) {
19798
+ return walkAccessExpression(name.parent);
19799
+ }
19800
+ function walkAccessExpression(access) {
19801
+ if (access.kind === 206 /* PropertyAccessExpression */) {
19802
+ var res = action(access.name);
19803
+ if (res !== undefined) {
19804
+ return res;
19805
+ }
19806
+ }
19807
+ else if (access.kind === 207 /* ElementAccessExpression */) {
19808
+ if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) {
19809
+ var res = action(access.argumentExpression);
19810
+ if (res !== undefined) {
19811
+ return res;
19812
+ }
19813
+ }
19814
+ else {
19815
+ // Chain interrupted by non-static-name access 'x[expr()].y.z'
19816
+ return undefined;
19817
+ }
19818
+ }
19819
+ if (isAccessExpression(access.expression)) {
19820
+ return walkAccessExpression(access.expression);
19821
+ }
19822
+ if (ts.isIdentifier(access.expression)) {
19823
+ // End of chain at Identifier 'x.y.z'
19824
+ return action(access.expression);
19825
+ }
19826
+ // End of chain at non-Identifier 'x().y.z'
19827
+ return undefined;
19828
+ }
19829
+ }
19830
+ ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft;
19781
19831
  function getLeftmostExpression(node, stopAtCallExpressions) {
19782
19832
  while (true) {
19783
19833
  switch (node.kind) {
@@ -20725,6 +20775,7 @@ var ts;
20725
20775
  ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
20726
20776
  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 */]];
20727
20777
  var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
20778
+ ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
20728
20779
  function getSupportedExtensions(options, extraFileExtensions) {
20729
20780
  var needJsExtensions = options && getAllowJSCompilerOption(options);
20730
20781
  if (!extraFileExtensions || extraFileExtensions.length === 0) {
@@ -21413,6 +21464,11 @@ var ts;
21413
21464
  return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
21414
21465
  }
21415
21466
  ts.getNodeModulePathParts = getNodeModulePathParts;
21467
+ function getParameterTypeNode(parameter) {
21468
+ var _a;
21469
+ return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
21470
+ }
21471
+ ts.getParameterTypeNode = getParameterTypeNode;
21416
21472
  })(ts || (ts = {}));
21417
21473
  /* @internal */
21418
21474
  var ts;
@@ -35566,34 +35622,10 @@ var ts;
35566
35622
  case 20 /* OpenParenToken */: // foo<x>(
35567
35623
  case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
35568
35624
  case 15 /* TemplateHead */: // foo<T> `...${100}...`
35569
- // These tokens can't follow in a call expression, nor can they start an
35570
- // expression. So, consider the type argument list part of an instantiation
35571
- // expression.
35572
- // falls through
35573
- case 27 /* CommaToken */: // foo<x>,
35574
- case 24 /* DotToken */: // foo<x>.
35575
- case 28 /* QuestionDotToken */: // foo<x>?.
35576
- case 21 /* CloseParenToken */: // foo<x>)
35577
- case 23 /* CloseBracketToken */: // foo<x>]
35578
- case 58 /* ColonToken */: // foo<x>:
35579
- case 26 /* SemicolonToken */: // foo<x>;
35580
- case 57 /* QuestionToken */: // foo<x>?
35581
- case 34 /* EqualsEqualsToken */: // foo<x> ==
35582
- case 36 /* EqualsEqualsEqualsToken */: // foo<x> ===
35583
- case 35 /* ExclamationEqualsToken */: // foo<x> !=
35584
- case 37 /* ExclamationEqualsEqualsToken */: // foo<x> !==
35585
- case 55 /* AmpersandAmpersandToken */: // foo<x> &&
35586
- case 56 /* BarBarToken */: // foo<x> ||
35587
- case 60 /* QuestionQuestionToken */: // foo<x> ??
35588
- case 52 /* CaretToken */: // foo<x> ^
35589
- case 50 /* AmpersandToken */: // foo<x> &
35590
- case 51 /* BarToken */: // foo<x> |
35591
- case 19 /* CloseBraceToken */: // foo<x> }
35592
- case 1 /* EndOfFileToken */: // foo<x>
35593
35625
  return true;
35594
35626
  }
35595
- // Treat anything else as an expression.
35596
- return false;
35627
+ // Consider something a type argument list only if the following token can't start an expression.
35628
+ return !isStartOfExpression();
35597
35629
  }
35598
35630
  function parsePrimaryExpression() {
35599
35631
  switch (token()) {
@@ -38811,7 +38843,7 @@ var ts;
38811
38843
  })(IncrementalParser || (IncrementalParser = {}));
38812
38844
  /** @internal */
38813
38845
  function isDeclarationFileName(fileName) {
38814
- return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
38846
+ return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions);
38815
38847
  }
38816
38848
  ts.isDeclarationFileName = isDeclarationFileName;
38817
38849
  function parseResolutionMode(mode, pos, end, reportDiagnostic) {
@@ -42319,7 +42351,8 @@ var ts;
42319
42351
  Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
42320
42352
  Extensions[Extensions["Json"] = 2] = "Json";
42321
42353
  Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
42322
- Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */
42354
+ Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
42355
+ Extensions[Extensions["TsOnly"] = 5] = "TsOnly";
42323
42356
  })(Extensions || (Extensions = {}));
42324
42357
  /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
42325
42358
  function resolvedTypeScriptOnly(resolved) {
@@ -43264,7 +43297,21 @@ var ts;
43264
43297
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43265
43298
  }
43266
43299
  function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
43267
- return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
43300
+ var extensions;
43301
+ if (lookupConfig) {
43302
+ extensions = tsconfigExtensions;
43303
+ }
43304
+ else if (compilerOptions.noDtsResolution) {
43305
+ extensions = [Extensions.TsOnly];
43306
+ if (compilerOptions.allowJs)
43307
+ extensions.push(Extensions.JavaScript);
43308
+ if (compilerOptions.resolveJsonModule)
43309
+ extensions.push(Extensions.Json);
43310
+ }
43311
+ else {
43312
+ extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
43313
+ }
43314
+ return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
43268
43315
  }
43269
43316
  ts.nodeModuleNameResolver = nodeModuleNameResolver;
43270
43317
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
@@ -43273,6 +43320,10 @@ var ts;
43273
43320
  var failedLookupLocations = [];
43274
43321
  // conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
43275
43322
  //it's essentially a set (priority is determined by object insertion order in the object we look at).
43323
+ var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
43324
+ if (compilerOptions.noDtsResolution) {
43325
+ conditions.pop();
43326
+ }
43276
43327
  var state = {
43277
43328
  compilerOptions: compilerOptions,
43278
43329
  host: host,
@@ -43280,7 +43331,7 @@ var ts;
43280
43331
  failedLookupLocations: failedLookupLocations,
43281
43332
  packageJsonInfoCache: cache,
43282
43333
  features: features,
43283
- conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
43334
+ conditions: conditions,
43284
43335
  };
43285
43336
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43286
43337
  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);
@@ -43456,9 +43507,9 @@ var ts;
43456
43507
  }
43457
43508
  }
43458
43509
  function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
43459
- if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) {
43510
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
43460
43511
  var result = tryFile(candidate, onlyRecordFailures, state);
43461
- 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;
43512
+ return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
43462
43513
  }
43463
43514
  return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
43464
43515
  }
@@ -43488,20 +43539,22 @@ var ts;
43488
43539
  default: return tryExtension(".d.ts" /* Dts */);
43489
43540
  }
43490
43541
  case Extensions.TypeScript:
43542
+ case Extensions.TsOnly:
43543
+ var useDts = extensions === Extensions.TypeScript;
43491
43544
  switch (originalExtension) {
43492
43545
  case ".mjs" /* Mjs */:
43493
43546
  case ".mts" /* Mts */:
43494
43547
  case ".d.mts" /* Dmts */:
43495
- return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
43548
+ return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
43496
43549
  case ".cjs" /* Cjs */:
43497
43550
  case ".cts" /* Cts */:
43498
43551
  case ".d.cts" /* Dcts */:
43499
- return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
43552
+ return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
43500
43553
  case ".json" /* Json */:
43501
43554
  candidate += ".json" /* Json */;
43502
- return tryExtension(".d.ts" /* Dts */);
43555
+ return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
43503
43556
  default:
43504
- return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
43557
+ return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
43505
43558
  }
43506
43559
  case Extensions.JavaScript:
43507
43560
  switch (originalExtension) {
@@ -43728,6 +43781,7 @@ var ts;
43728
43781
  switch (extensions) {
43729
43782
  case Extensions.JavaScript:
43730
43783
  case Extensions.Json:
43784
+ case Extensions.TsOnly:
43731
43785
  packageFile = readPackageJsonMainField(jsonContent, candidate, state);
43732
43786
  break;
43733
43787
  case Extensions.TypeScript:
@@ -43800,14 +43854,16 @@ var ts;
43800
43854
  function extensionIsOk(extensions, extension) {
43801
43855
  switch (extensions) {
43802
43856
  case Extensions.JavaScript:
43803
- return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
43857
+ return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */;
43804
43858
  case Extensions.TSConfig:
43805
43859
  case Extensions.Json:
43806
43860
  return extension === ".json" /* Json */;
43807
43861
  case Extensions.TypeScript:
43808
- return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
43862
+ 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 */;
43863
+ case Extensions.TsOnly:
43864
+ return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */;
43809
43865
  case Extensions.DtsOnly:
43810
- return extension === ".d.ts" /* Dts */;
43866
+ return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
43811
43867
  }
43812
43868
  }
43813
43869
  /* @internal */
@@ -53109,9 +53165,6 @@ var ts;
53109
53165
  if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
53110
53166
  parameterType = getOptionalType(parameterType);
53111
53167
  }
53112
- if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
53113
- parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */);
53114
- }
53115
53168
  var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
53116
53169
  var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
53117
53170
  var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
@@ -53670,7 +53723,7 @@ var ts;
53670
53723
  if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
53671
53724
  // try to reuse the existing annotation
53672
53725
  var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
53673
- if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
53726
+ if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
53674
53727
  var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
53675
53728
  if (result_6) {
53676
53729
  return result_6;
@@ -53687,6 +53740,16 @@ var ts;
53687
53740
  context.flags = oldFlags;
53688
53741
  return result;
53689
53742
  }
53743
+ function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
53744
+ var typeFromTypeNode = getTypeFromTypeNode(typeNode);
53745
+ if (typeFromTypeNode === type) {
53746
+ return true;
53747
+ }
53748
+ if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
53749
+ return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
53750
+ }
53751
+ return false;
53752
+ }
53690
53753
  function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
53691
53754
  if (!isErrorType(type) && context.enclosingDeclaration) {
53692
53755
  var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
@@ -55958,7 +56021,7 @@ var ts;
55958
56021
  }
55959
56022
  }
55960
56023
  var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
55961
- type = getUnionType(sourceTypes, 2 /* Subtype */);
56024
+ type = getUnionType(sourceTypes);
55962
56025
  }
55963
56026
  }
55964
56027
  var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
@@ -58707,8 +58770,9 @@ var ts;
58707
58770
  // levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
58708
58771
  // yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
58709
58772
  // nesting, so it is effectively just a safety stop.
58710
- if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) {
58711
- stack.push(t);
58773
+ var identity_1 = getRecursionIdentity(t);
58774
+ if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
58775
+ stack.push(identity_1);
58712
58776
  result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
58713
58777
  stack.pop();
58714
58778
  }
@@ -66906,12 +66970,12 @@ var ts;
66906
66970
  function isDeeplyNestedType(type, stack, depth, maxDepth) {
66907
66971
  if (maxDepth === void 0) { maxDepth = 3; }
66908
66972
  if (depth >= maxDepth) {
66909
- var identity_1 = getRecursionIdentity(type);
66973
+ var identity_2 = getRecursionIdentity(type);
66910
66974
  var count = 0;
66911
66975
  var lastTypeId = 0;
66912
66976
  for (var i = 0; i < depth; i++) {
66913
66977
  var t = stack[i];
66914
- if (getRecursionIdentity(t) === identity_1) {
66978
+ if (getRecursionIdentity(t) === identity_2) {
66915
66979
  // We only count occurrences with a higher type id than the previous occurrence, since higher
66916
66980
  // type ids are an indicator of newer instantiations caused by recursion.
66917
66981
  if (t.id >= lastTypeId) {
@@ -79725,11 +79789,16 @@ var ts;
79725
79789
  if (constraintType && defaultType) {
79726
79790
  checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
79727
79791
  }
79728
- if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) {
79792
+ checkNodeDeferred(node);
79793
+ addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79794
+ }
79795
+ function checkTypeParameterDeferred(node) {
79796
+ if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) {
79797
+ var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
79729
79798
  var modifiers = getVarianceModifiers(typeParameter);
79730
79799
  if (modifiers) {
79731
79800
  var symbol = getSymbolOfNode(node.parent);
79732
- if (node.parent.kind === 259 /* TypeAliasDeclaration */ && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
79801
+ if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
79733
79802
  error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
79734
79803
  }
79735
79804
  else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
@@ -79742,7 +79811,6 @@ var ts;
79742
79811
  }
79743
79812
  }
79744
79813
  }
79745
- addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79746
79814
  }
79747
79815
  function checkParameter(node) {
79748
79816
  // Grammar checking
@@ -80232,7 +80300,7 @@ var ts;
80232
80300
  superCallStatement = statement;
80233
80301
  break;
80234
80302
  }
80235
- if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
80303
+ if (nodeImmediatelyReferencesSuperOrThis(statement)) {
80236
80304
  break;
80237
80305
  }
80238
80306
  }
@@ -85585,6 +85653,9 @@ var ts;
85585
85653
  case 226 /* ClassExpression */:
85586
85654
  checkClassExpressionDeferred(node);
85587
85655
  break;
85656
+ case 163 /* TypeParameter */:
85657
+ checkTypeParameterDeferred(node);
85658
+ break;
85588
85659
  case 279 /* JsxSelfClosingElement */:
85589
85660
  checkJsxSelfClosingElementDeferred(node);
85590
85661
  break;
@@ -86681,11 +86752,6 @@ var ts;
86681
86752
  !parameter.initializer &&
86682
86753
  ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
86683
86754
  }
86684
- function isOptionalUninitializedParameter(parameter) {
86685
- return !!strictNullChecks &&
86686
- isOptionalParameter(parameter) &&
86687
- !parameter.initializer;
86688
- }
86689
86755
  function isExpandoFunctionDeclaration(node) {
86690
86756
  var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
86691
86757
  if (!declaration) {
@@ -87602,8 +87668,7 @@ var ts;
87602
87668
  case 144 /* OutKeyword */:
87603
87669
  var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */;
87604
87670
  var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out";
87605
- if (node.kind !== 163 /* TypeParameter */ || (node.parent.kind !== 258 /* InterfaceDeclaration */ &&
87606
- node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) {
87671
+ if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) {
87607
87672
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
87608
87673
  }
87609
87674
  if (flags & inOutFlag) {
@@ -92837,11 +92902,11 @@ var ts;
92837
92902
  }
92838
92903
  var statements = [];
92839
92904
  resumeLexicalEnvironment();
92840
- var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
92841
- var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
92905
+ var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
92906
+ var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount);
92842
92907
  // If there was a super call, visit existing statements up to and including it
92843
92908
  if (superStatementIndex >= 0) {
92844
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
92909
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount));
92845
92910
  }
92846
92911
  // Transform parameters into property assignments. Transforms this:
92847
92912
  //
@@ -92860,12 +92925,12 @@ var ts;
92860
92925
  if (superStatementIndex >= 0) {
92861
92926
  ts.addRange(statements, parameterPropertyAssignments);
92862
92927
  }
92863
- // Since there was no super() call, parameter properties are the first statements in the constructor
92928
+ // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements
92864
92929
  else {
92865
- statements = ts.addRange(parameterPropertyAssignments, statements);
92930
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
92866
92931
  }
92867
- // Add remaining statements from the body, skipping the super() call if it was found
92868
- ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
92932
+ // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
92933
+ ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
92869
92934
  // End the lexical environment.
92870
92935
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
92871
92936
  var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
@@ -109764,7 +109829,7 @@ var ts;
109764
109829
  addOutput(buildInfoPath);
109765
109830
  }
109766
109831
  function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
109767
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
109832
+ if (ts.isDeclarationFileName(inputFileName))
109768
109833
  return;
109769
109834
  var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
109770
109835
  addOutput(js);
@@ -109809,7 +109874,7 @@ var ts;
109809
109874
  /*@internal*/
109810
109875
  function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
109811
109876
  var options = _a.options, fileNames = _a.fileNames;
109812
- 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));
109877
+ 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));
109813
109878
  }
109814
109879
  ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
109815
109880
  /*@internal*/
@@ -109851,7 +109916,7 @@ var ts;
109851
109916
  var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
109852
109917
  for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
109853
109918
  var inputFileName = _b[_a];
109854
- if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */))
109919
+ if (ts.isDeclarationFileName(inputFileName))
109855
109920
  continue;
109856
109921
  var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
109857
109922
  if (jsFilePath)
@@ -115201,7 +115266,7 @@ var ts;
115201
115266
  if (ts.outFile(options) || options.outDir)
115202
115267
  return false;
115203
115268
  // File if emitted next to input needs to be ignored
115204
- if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) {
115269
+ if (ts.isDeclarationFileName(fileOrDirectoryPath)) {
115205
115270
  // If its declaration directory: its not ignored if not excluded by config
115206
115271
  if (options.declarationDir)
115207
115272
  return false;
@@ -116374,7 +116439,7 @@ var ts;
116374
116439
  var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
116375
116440
  for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
116376
116441
  var fileName = _c[_b];
116377
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
116442
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
116378
116443
  processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
116379
116444
  }
116380
116445
  }
@@ -116565,7 +116630,7 @@ var ts;
116565
116630
  }
116566
116631
  function getRedirectReferenceForResolution(file) {
116567
116632
  var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
116568
- if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]))
116633
+ if (redirect || !ts.isDeclarationFileName(file.originalFileName))
116569
116634
  return redirect;
116570
116635
  // The originalFileName could not be actual source file name if file found was d.ts from referecned project
116571
116636
  // 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
@@ -117956,7 +118021,7 @@ var ts;
117956
118021
  }
117957
118022
  function getProjectReferenceRedirectProject(fileName) {
117958
118023
  // Ignore dts or any json files
117959
- if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
118024
+ if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
117960
118025
  return undefined;
117961
118026
  }
117962
118027
  // If this file is produced by a referenced project, we need to rewrite it to
@@ -118005,7 +118070,7 @@ var ts;
118005
118070
  else {
118006
118071
  var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
118007
118072
  ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
118008
- if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
118073
+ if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
118009
118074
  var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
118010
118075
  mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
118011
118076
  }
@@ -118806,7 +118871,7 @@ var ts;
118806
118871
  if (options.outDir) {
118807
118872
  return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
118808
118873
  }
118809
- if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) {
118874
+ if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) {
118810
118875
  // Otherwise just check if sourceFile with the name exists
118811
118876
  var filePathWithoutExtension = ts.removeFileExtension(filePath);
118812
118877
  return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
@@ -119432,7 +119497,7 @@ var ts;
119432
119497
  /*forceDtsEmit*/ true);
119433
119498
  var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
119434
119499
  if (firstDts_1) {
119435
- 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; })); });
119500
+ 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; })); });
119436
119501
  latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
119437
119502
  if (exportedModulesMapCache && latestSignature !== prevSignature) {
119438
119503
  updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
@@ -119837,7 +119902,7 @@ var ts;
119837
119902
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
119838
119903
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
119839
119904
  */
119840
- function getNextAffectedFile(state, cancellationToken, computeHash) {
119905
+ function getNextAffectedFile(state, cancellationToken, computeHash, host) {
119841
119906
  while (true) {
119842
119907
  var affectedFiles = state.affectedFiles;
119843
119908
  if (affectedFiles) {
@@ -119848,7 +119913,7 @@ var ts;
119848
119913
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
119849
119914
  // Set the next affected file as seen and remove the cached semantic diagnostics
119850
119915
  state.affectedFilesIndex = affectedFilesIndex;
119851
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
119916
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
119852
119917
  return affectedFile;
119853
119918
  }
119854
119919
  affectedFilesIndex++;
@@ -119889,6 +119954,11 @@ var ts;
119889
119954
  state.seenAffectedFiles = new ts.Set();
119890
119955
  }
119891
119956
  }
119957
+ function clearAffectedFilesPendingEmit(state) {
119958
+ state.affectedFilesPendingEmit = undefined;
119959
+ state.affectedFilesPendingEmitKind = undefined;
119960
+ state.affectedFilesPendingEmitIndex = undefined;
119961
+ }
119892
119962
  /**
119893
119963
  * Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
119894
119964
  */
@@ -119908,9 +119978,7 @@ var ts;
119908
119978
  }
119909
119979
  }
119910
119980
  }
119911
- state.affectedFilesPendingEmit = undefined;
119912
- state.affectedFilesPendingEmitKind = undefined;
119913
- state.affectedFilesPendingEmitIndex = undefined;
119981
+ clearAffectedFilesPendingEmit(state);
119914
119982
  }
119915
119983
  return undefined;
119916
119984
  }
@@ -119918,7 +119986,7 @@ var ts;
119918
119986
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
119919
119987
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
119920
119988
  */
119921
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
119989
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
119922
119990
  var _a;
119923
119991
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
119924
119992
  // If affected files is everything except default library, then nothing more to do
@@ -119943,14 +120011,14 @@ var ts;
119943
120011
  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);
119944
120012
  }
119945
120013
  if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
119946
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
120014
+ forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
119947
120015
  }
119948
120016
  }
119949
120017
  /**
119950
120018
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
119951
120019
  * Also we need to make sure signature is updated for these files
119952
120020
  */
119953
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
120021
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
119954
120022
  removeSemanticDiagnosticsOf(state, path);
119955
120023
  if (!state.changedFilesSet.has(path)) {
119956
120024
  var program = ts.Debug.checkDefined(state.program);
@@ -119961,8 +120029,7 @@ var ts;
119961
120029
  // This ensures that we dont later during incremental builds considering wrong signature.
119962
120030
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
119963
120031
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
119964
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap,
119965
- /* useFileVersionAsSignature */ true);
120032
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
119966
120033
  // If not dts emit, nothing more to do
119967
120034
  if (ts.getEmitDeclarations(state.compilerOptions)) {
119968
120035
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -120159,13 +120226,18 @@ var ts;
120159
120226
  var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
120160
120227
  var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
120161
120228
  return value.version === actualSignature ?
120162
- value.affectsGlobalScope ?
120163
- { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
120229
+ value.affectsGlobalScope || value.impliedFormat ?
120230
+ // If file version is same as signature, dont serialize signature
120231
+ { version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120232
+ // If file info only contains version and signature and both are same we can just write string
120164
120233
  value.version :
120165
- actualSignature !== undefined ?
120234
+ actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
120166
120235
  signature === undefined ?
120236
+ // If we havent computed signature, use fileInfo as is
120167
120237
  value :
120238
+ // Serialize fileInfo with new updated signature
120168
120239
  { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
120240
+ // Signature of the FileInfo is undefined, serialize it as false
120169
120241
  { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
120170
120242
  });
120171
120243
  var referencedMap;
@@ -120410,7 +120482,7 @@ var ts;
120410
120482
  * in that order would be used to write the files
120411
120483
  */
120412
120484
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
120413
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
120485
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
120414
120486
  var emitKind = 1 /* Full */;
120415
120487
  var isPendingEmitFile = false;
120416
120488
  if (!affected) {
@@ -120455,54 +120527,48 @@ var ts;
120455
120527
  * in that order would be used to write the files
120456
120528
  */
120457
120529
  function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
120458
- var restorePendingEmitOnHandlingNoEmitSuccess = false;
120459
- var savedAffectedFilesPendingEmit;
120460
- var savedAffectedFilesPendingEmitKind;
120461
- var savedAffectedFilesPendingEmitIndex;
120462
- // 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
120463
- // This ensures pending files to emit is updated in tsbuildinfo
120464
- // 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)
120465
- if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
120466
- !targetSourceFile &&
120467
- !ts.outFile(state.compilerOptions) &&
120468
- !state.compilerOptions.noEmit &&
120469
- state.compilerOptions.noEmitOnError) {
120470
- restorePendingEmitOnHandlingNoEmitSuccess = true;
120471
- savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
120472
- savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
120473
- savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
120474
- }
120530
+ var _a;
120475
120531
  if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120476
120532
  assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
120477
120533
  }
120478
120534
  var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
120479
120535
  if (result)
120480
120536
  return result;
120481
- if (restorePendingEmitOnHandlingNoEmitSuccess) {
120482
- state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
120483
- state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
120484
- state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
120485
- }
120486
120537
  // Emit only affected files if using builder for emit
120487
- if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120488
- // Emit and report any errors we ran into.
120489
- var sourceMaps = [];
120490
- var emitSkipped = false;
120491
- var diagnostics = void 0;
120492
- var emittedFiles = [];
120493
- var affectedEmitResult = void 0;
120494
- while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
120495
- emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
120496
- diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
120497
- emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
120498
- sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
120538
+ if (!targetSourceFile) {
120539
+ if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
120540
+ // Emit and report any errors we ran into.
120541
+ var sourceMaps = [];
120542
+ var emitSkipped = false;
120543
+ var diagnostics = void 0;
120544
+ var emittedFiles = [];
120545
+ var affectedEmitResult = void 0;
120546
+ while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
120547
+ emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
120548
+ diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
120549
+ emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
120550
+ sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
120551
+ }
120552
+ return {
120553
+ emitSkipped: emitSkipped,
120554
+ diagnostics: diagnostics || ts.emptyArray,
120555
+ emittedFiles: emittedFiles,
120556
+ sourceMaps: sourceMaps
120557
+ };
120558
+ }
120559
+ // In non Emit builder, clear affected files pending emit
120560
+ else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) {
120561
+ ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram);
120562
+ // State can clear affected files pending emit if
120563
+ if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared
120564
+ // If every file pending emit is pending on only dts emit
120565
+ || ts.every(state.affectedFilesPendingEmit, function (path, index) {
120566
+ return index < state.affectedFilesPendingEmitIndex ||
120567
+ state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */;
120568
+ })) {
120569
+ clearAffectedFilesPendingEmit(state);
120570
+ }
120499
120571
  }
120500
- return {
120501
- emitSkipped: emitSkipped,
120502
- diagnostics: diagnostics || ts.emptyArray,
120503
- emittedFiles: emittedFiles,
120504
- sourceMaps: sourceMaps
120505
- };
120506
120572
  }
120507
120573
  return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120508
120574
  }
@@ -120512,7 +120578,7 @@ var ts;
120512
120578
  */
120513
120579
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
120514
120580
  while (true) {
120515
- var affected = getNextAffectedFile(state, cancellationToken, computeHash);
120581
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
120516
120582
  if (!affected) {
120517
120583
  // Done
120518
120584
  return undefined;
@@ -123632,9 +123698,6 @@ var ts;
123632
123698
  function newer(date1, date2) {
123633
123699
  return date2 > date1 ? date2 : date1;
123634
123700
  }
123635
- function isDeclarationFile(fileName) {
123636
- return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
123637
- }
123638
123701
  /*@internal*/
123639
123702
  function isCircularBuildOrder(buildOrder) {
123640
123703
  return !!buildOrder && !!buildOrder.buildOrder;
@@ -124197,7 +124260,7 @@ var ts;
124197
124260
  outputFiles.forEach(function (_a) {
124198
124261
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
124199
124262
  var priorChangeTime;
124200
- if (!anyDtsChanged && isDeclarationFile(name)) {
124263
+ if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
124201
124264
  // Check for unchanged .d.ts files
124202
124265
  if (host.fileExists(name) && state.readFileWithCache(name) === text) {
124203
124266
  priorChangeTime = host.getModifiedTime(name);
@@ -124538,7 +124601,7 @@ var ts;
124538
124601
  // In addition to file timestamps, we also keep track of when a .d.ts file
124539
124602
  // had its file touched but not had its contents changed - this allows us
124540
124603
  // to skip a downstream typecheck
124541
- if (isDeclarationFile(output)) {
124604
+ if (ts.isDeclarationFileName(output)) {
124542
124605
  var outputModifiedTime = ts.getModifiedTime(host, output);
124543
124606
  newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
124544
124607
  }
@@ -124692,7 +124755,7 @@ var ts;
124692
124755
  reportVerbose = false;
124693
124756
  reportStatus(state, verboseMessage, proj.options.configFilePath);
124694
124757
  }
124695
- if (isDeclarationFile(file)) {
124758
+ if (ts.isDeclarationFileName(file)) {
124696
124759
  priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
124697
124760
  }
124698
124761
  host.setModifiedTime(file, now);
@@ -132004,17 +132067,13 @@ var ts;
132004
132067
  }
132005
132068
  }
132006
132069
  if (origin && originIsObjectLiteralMethod(origin)) {
132007
- var importAdder = void 0;
132008
- (insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails);
132070
+ (insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails);
132009
132071
  if (!preferences.useLabelDetailsInCompletionEntries) {
132010
132072
  name = name + labelDetails.detail;
132011
132073
  labelDetails = undefined;
132012
132074
  }
132013
132075
  source = CompletionSource.ObjectLiteralMethodSnippet;
132014
132076
  sortText = Completions.SortText.SortBelow(sortText);
132015
- if (importAdder.hasFixes()) {
132016
- hasAction = true;
132017
- }
132018
132077
  }
132019
132078
  if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
132020
132079
  var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
@@ -132237,8 +132296,7 @@ var ts;
132237
132296
  var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
132238
132297
  var insertText = name;
132239
132298
  var sourceFile = enclosingDeclaration.getSourceFile();
132240
- var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
132241
- var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
132299
+ var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences);
132242
132300
  if (!method) {
132243
132301
  return undefined;
132244
132302
  }
@@ -132267,16 +132325,15 @@ var ts;
132267
132325
  /*modifiers*/ undefined,
132268
132326
  /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type);
132269
132327
  var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) };
132270
- return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, labelDetails: labelDetails };
132328
+ return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
132271
132329
  }
132272
132330
  ;
132273
- function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) {
132331
+ function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
132274
132332
  var declarations = symbol.getDeclarations();
132275
132333
  if (!(declarations && declarations.length)) {
132276
132334
  return undefined;
132277
132335
  }
132278
132336
  var checker = program.getTypeChecker();
132279
- var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
132280
132337
  var declaration = declarations[0];
132281
132338
  var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
132282
132339
  var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
@@ -132309,11 +132366,6 @@ var ts;
132309
132366
  if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
132310
132367
  return undefined;
132311
132368
  }
132312
- var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
132313
- if (importableReference) {
132314
- typeNode = importableReference.typeNode;
132315
- ts.codefix.importSymbols(importAdder, importableReference.symbols);
132316
- }
132317
132369
  var body = void 0;
132318
132370
  if (preferences.includeCompletionsWithSnippetText) {
132319
132371
  var emptyStmt = ts.factory.createEmptyStatement();
@@ -132323,11 +132375,19 @@ var ts;
132323
132375
  else {
132324
132376
  body = ts.factory.createBlock([], /* multiline */ true);
132325
132377
  }
132378
+ var parameters = typeNode.parameters.map(function (typedParam) {
132379
+ return ts.factory.createParameterDeclaration(
132380
+ /*decorators*/ undefined,
132381
+ /*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken,
132382
+ /*type*/ undefined, typedParam.initializer);
132383
+ });
132326
132384
  return ts.factory.createMethodDeclaration(
132327
132385
  /*decorators*/ undefined,
132328
132386
  /*modifiers*/ undefined,
132329
132387
  /*asteriskToken*/ undefined, name,
132330
- /*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body);
132388
+ /*questionToken*/ undefined,
132389
+ /*typeParameters*/ undefined, parameters,
132390
+ /*type*/ undefined, body);
132331
132391
  }
132332
132392
  default:
132333
132393
  return undefined;
@@ -132690,20 +132750,6 @@ var ts;
132690
132750
  };
132691
132751
  }
132692
132752
  }
132693
- if (source === CompletionSource.ObjectLiteralMethodSnippet) {
132694
- var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
132695
- var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
132696
- if (importAdder.hasFixes()) {
132697
- var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
132698
- return {
132699
- sourceDisplay: undefined,
132700
- codeActions: [{
132701
- changes: changes,
132702
- description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
132703
- }],
132704
- };
132705
- }
132706
- }
132707
132753
  if (originIsTypeOnlyAlias(origin)) {
132708
132754
  var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
132709
132755
  ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
@@ -135524,7 +135570,7 @@ var ts;
135524
135570
  // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
135525
135571
  // If this occurs unexpectedly, the fix is likely to synchronize the project settings.
135526
135572
  // Skip .d.ts files to reduce noise (should also cover most of node_modules).
135527
- var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) &&
135573
+ var otherBucketKey = !ts.isDeclarationFileName(path) &&
135528
135574
  ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
135529
135575
  if (otherBucketKey) {
135530
135576
  ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
@@ -137464,6 +137510,30 @@ var ts;
137464
137510
  }
137465
137511
  }
137466
137512
  Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
137513
+ function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
137514
+ var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
137515
+ return candidates.reduce(function (topMost, decl) {
137516
+ var depth = getDepth(decl);
137517
+ if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
137518
+ topMost.declarationNames.push(decl);
137519
+ topMost.depth = depth;
137520
+ }
137521
+ else if (depth < topMost.depth) {
137522
+ topMost.declarationNames = [decl];
137523
+ topMost.depth = depth;
137524
+ }
137525
+ return topMost;
137526
+ }, { depth: Infinity, declarationNames: [] }).declarationNames;
137527
+ function getDepth(declaration) {
137528
+ var depth = 0;
137529
+ while (declaration) {
137530
+ declaration = ts.getContainerNode(declaration);
137531
+ depth++;
137532
+ }
137533
+ return depth;
137534
+ }
137535
+ }
137536
+ Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
137467
137537
  function someSignatureUsage(signature, sourceFiles, checker, cb) {
137468
137538
  if (!signature.name || !ts.isIdentifier(signature.name))
137469
137539
  return false;
@@ -139100,7 +139170,9 @@ var ts;
139100
139170
  (function (ts) {
139101
139171
  var GoToDefinition;
139102
139172
  (function (GoToDefinition) {
139103
- function getDefinitionAtPosition(program, sourceFile, position) {
139173
+ function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly) {
139174
+ var _a;
139175
+ var _b;
139104
139176
  var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
139105
139177
  var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
139106
139178
  if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
@@ -139123,33 +139195,63 @@ var ts;
139123
139195
  }
139124
139196
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
139125
139197
  var classDecl = node.parent.parent;
139126
- var symbol_1 = getSymbol(classDecl, typeChecker);
139198
+ var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
139127
139199
  var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
139128
139200
  var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
139129
139201
  var sourceFile_1 = node.getSourceFile();
139130
139202
  return ts.map(staticBlocks, function (staticBlock) {
139131
139203
  var pos = ts.moveRangePastModifiers(staticBlock).pos;
139132
139204
  pos = ts.skipTrivia(sourceFile_1.text, pos);
139133
- return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
139205
+ return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length });
139134
139206
  });
139135
139207
  }
139136
- var symbol = getSymbol(node, typeChecker);
139208
+ var _d = getSymbol(node, typeChecker), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
139209
+ var fallbackNode = node;
139210
+ if (searchOtherFilesOnly && failedAliasResolution) {
139211
+ // We couldn't resolve the specific import, try on the module specifier.
139212
+ 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); });
139213
+ var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
139214
+ if (moduleSpecifier) {
139215
+ (_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
139216
+ fallbackNode = moduleSpecifier;
139217
+ }
139218
+ }
139219
+ if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
139220
+ // We couldn't resolve the module specifier as an external module, but it could
139221
+ // be that module resolution succeeded but the target was not a module.
139222
+ var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
139223
+ if (ref) {
139224
+ return [{
139225
+ name: fallbackNode.text,
139226
+ fileName: ref.resolvedFileName,
139227
+ containerName: undefined,
139228
+ containerKind: undefined,
139229
+ kind: "script" /* scriptElement */,
139230
+ textSpan: ts.createTextSpan(0, 0),
139231
+ failedAliasResolution: failedAliasResolution,
139232
+ isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
139233
+ unverified: fallbackNode !== node,
139234
+ }];
139235
+ }
139236
+ }
139137
139237
  // Could not find a symbol e.g. node is string or number keyword,
139138
139238
  // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
139139
139239
  if (!symbol) {
139140
139240
  return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
139141
139241
  }
139242
+ if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
139243
+ return undefined;
139142
139244
  var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
139143
139245
  // Don't go to the component constructor definition for a JSX element, just go to the component definition.
139144
139246
  if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
139145
- var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
139247
+ var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
139146
139248
  // For a function, if this is the original function definition, return just sigInfo.
139147
139249
  // If this is the original constructor definition, parent is the class.
139148
139250
  if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
139149
139251
  return [sigInfo];
139150
139252
  }
139151
139253
  else {
139152
- var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
139254
+ var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
139153
139255
  // For a 'super()' call, put the signature first, else put the variable first.
139154
139256
  return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
139155
139257
  }
@@ -139161,7 +139263,7 @@ var ts;
139161
139263
  // assignment. This case and others are handled by the following code.
139162
139264
  if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) {
139163
139265
  var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
139164
- 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;
139266
+ 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;
139165
139267
  return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
139166
139268
  }
139167
139269
  // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
@@ -139184,7 +139286,7 @@ var ts;
139184
139286
  return prop && getDefinitionFromSymbol(typeChecker, prop, node);
139185
139287
  });
139186
139288
  }
139187
- return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
139289
+ return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
139188
139290
  }
139189
139291
  GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
139190
139292
  /**
@@ -139282,24 +139384,24 @@ var ts;
139282
139384
  return undefined;
139283
139385
  }
139284
139386
  if (ts.isImportMeta(node.parent) && node.parent.name === node) {
139285
- return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
139387
+ return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
139286
139388
  }
139287
- var symbol = getSymbol(node, typeChecker);
139389
+ var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
139288
139390
  if (!symbol)
139289
139391
  return undefined;
139290
139392
  var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
139291
139393
  var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
139292
- var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
139394
+ var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
139293
139395
  // If a function returns 'void' or some other type with no definition, just return the function definition.
139294
- var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
139396
+ var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
139295
139397
  return typeDefinitions.length ? typeDefinitions
139296
- : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
139398
+ : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
139297
139399
  : undefined;
139298
139400
  }
139299
139401
  GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
139300
- function definitionFromType(type, checker, node) {
139402
+ function definitionFromType(type, checker, node, failedAliasResolution) {
139301
139403
  return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
139302
- return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
139404
+ return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
139303
139405
  });
139304
139406
  }
139305
139407
  function tryGetReturnTypeOfFunction(symbol, type, checker) {
@@ -139341,13 +139443,17 @@ var ts;
139341
139443
  // get the aliased symbol instead. This allows for goto def on an import e.g.
139342
139444
  // import {A, B} from "mod";
139343
139445
  // to jump to the implementation directly.
139446
+ var failedAliasResolution = false;
139344
139447
  if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
139345
139448
  var aliased = checker.getAliasedSymbol(symbol);
139346
139449
  if (aliased.declarations) {
139347
- return aliased;
139450
+ return { symbol: aliased };
139451
+ }
139452
+ else {
139453
+ failedAliasResolution = true;
139348
139454
  }
139349
139455
  }
139350
- return symbol;
139456
+ return { symbol: symbol, failedAliasResolution: failedAliasResolution };
139351
139457
  }
139352
139458
  // Go to the original declaration for cases:
139353
139459
  //
@@ -139361,26 +139467,45 @@ var ts;
139361
139467
  if (node.parent === declaration) {
139362
139468
  return true;
139363
139469
  }
139364
- switch (declaration.kind) {
139365
- case 267 /* ImportClause */:
139366
- case 265 /* ImportEqualsDeclaration */:
139367
- return true;
139368
- case 270 /* ImportSpecifier */:
139369
- return declaration.parent.kind === 269 /* NamedImports */;
139370
- case 203 /* BindingElement */:
139371
- case 254 /* VariableDeclaration */:
139372
- return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
139373
- default:
139374
- return false;
139470
+ if (declaration.kind === 268 /* NamespaceImport */) {
139471
+ return false;
139375
139472
  }
139473
+ return true;
139474
+ }
139475
+ /**
139476
+ * ```ts
139477
+ * function f() {}
139478
+ * f.foo = 0;
139479
+ * ```
139480
+ *
139481
+ * Here, `f` has two declarations: the function declaration, and the identifier in the next line.
139482
+ * The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
139483
+ * it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
139484
+ * "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
139485
+ * declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
139486
+ * declaration looks like an assignment, that declaration is in no sense a definition for `f`.
139487
+ * But that information is totally lost during binding and/or symbol merging, so we need to do
139488
+ * our best to reconstruct it or use other heuristics. This function (and the logic around its
139489
+ * calling) covers our tests but feels like a hack, and it would be great if someone could come
139490
+ * up with a more precise definition of what counts as a definition.
139491
+ */
139492
+ function isExpandoDeclaration(node) {
139493
+ if (!ts.isAssignmentDeclaration(node))
139494
+ return false;
139495
+ var containingAssignment = ts.findAncestor(node, function (p) {
139496
+ if (ts.isAssignmentExpression(p))
139497
+ return true;
139498
+ if (!ts.isAssignmentDeclaration(p))
139499
+ return "quit";
139500
+ return false;
139501
+ });
139502
+ return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
139376
139503
  }
139377
- function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) {
139378
- // There are cases when you extend a function by adding properties to it afterwards,
139379
- // we want to strip those extra properties.
139380
- // For deduping purposes, we also want to exclude any declarationNodes if provided.
139381
- var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); })
139382
- || undefined;
139383
- return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
139504
+ function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
139505
+ var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
139506
+ var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
139507
+ var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
139508
+ return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); });
139384
139509
  function getConstructSignatureDefinition() {
139385
139510
  // Applicable only if we are in a new expression, or we are on a constructor declaration
139386
139511
  // and in either case the symbol has a construct signature definition, i.e. class
@@ -139404,26 +139529,27 @@ var ts;
139404
139529
  return declarations.length
139405
139530
  ? declarationsWithBody.length !== 0
139406
139531
  ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
139407
- : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
139532
+ : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)]
139408
139533
  : undefined;
139409
139534
  }
139410
139535
  }
139411
139536
  /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
139412
- function createDefinitionInfo(declaration, checker, symbol, node) {
139537
+ function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) {
139413
139538
  var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
139414
139539
  var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
139415
139540
  var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
139416
- return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
139541
+ return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution);
139417
139542
  }
139543
+ GoToDefinition.createDefinitionInfo = createDefinitionInfo;
139418
139544
  /** Creates a DefinitionInfo directly from the name of a declaration. */
139419
- function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
139545
+ function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) {
139420
139546
  var sourceFile = declaration.getSourceFile();
139421
139547
  if (!textSpan) {
139422
139548
  var name = ts.getNameOfDeclaration(declaration) || declaration;
139423
139549
  textSpan = ts.createTextSpanFromNode(name, sourceFile);
139424
139550
  }
139425
139551
  return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
139426
- containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
139552
+ containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution });
139427
139553
  }
139428
139554
  function isDefinitionVisible(checker, declaration) {
139429
139555
  if (checker.isDeclarationVisible(declaration))
@@ -139456,8 +139582,8 @@ var ts;
139456
139582
  return false;
139457
139583
  }
139458
139584
  }
139459
- function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
139460
- return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
139585
+ function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
139586
+ return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution);
139461
139587
  }
139462
139588
  function findReferenceInPosition(refs, pos) {
139463
139589
  return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
@@ -152572,9 +152698,10 @@ var ts;
152572
152698
  // 2. add "member3" to the second import statement's import list
152573
152699
  // and it is up to the user to decide which one fits best.
152574
152700
  return ts.firstDefined(existingImports, function (_a) {
152701
+ var _b;
152575
152702
  var declaration = _a.declaration;
152576
152703
  var namespacePrefix = getNamespaceLikeImportText(declaration);
152577
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
152704
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
152578
152705
  if (namespacePrefix && moduleSpecifier) {
152579
152706
  var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
152580
152707
  if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
@@ -152750,8 +152877,9 @@ var ts;
152750
152877
  return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
152751
152878
  }
152752
152879
  function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
152880
+ var _b;
152753
152881
  var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
152754
- var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
152882
+ var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
152755
152883
  if (moduleSpecifier) {
152756
152884
  var addAsTypeOnly = useRequire
152757
152885
  ? 4 /* NotAllowed */
@@ -157109,7 +157237,6 @@ var ts;
157109
157237
  var checker = program.getTypeChecker();
157110
157238
  var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
157111
157239
  var flags = 1 /* NoTruncation */
157112
- | 1073741824 /* NoUndefinedOptionalParameterType */
157113
157240
  | 256 /* SuppressAnyReturnType */
157114
157241
  | 524288 /* AllowEmptyTuple */
157115
157242
  | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
@@ -164690,9 +164817,9 @@ var ts;
164690
164817
  }
164691
164818
  }
164692
164819
  /// Goto definition
164693
- function getDefinitionAtPosition(fileName, position) {
164820
+ function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly) {
164694
164821
  synchronizeHostData();
164695
- return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
164822
+ return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly);
164696
164823
  }
164697
164824
  function getDefinitionAndBoundSpan(fileName, position) {
164698
164825
  synchronizeHostData();