typescript 4.6.0-dev.20211115 → 4.6.0-dev.20211119

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.
@@ -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.20211115";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20211119";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -356,26 +356,6 @@ var ts;
356
356
  ts.emptyArray = [];
357
357
  ts.emptyMap = new ts.Map();
358
358
  ts.emptySet = new ts.Set();
359
- function createMap() {
360
- return new ts.Map();
361
- }
362
- ts.createMap = createMap;
363
- /**
364
- * Create a new map from a template object is provided, the map will copy entries from it.
365
- * @deprecated Use `new Map(getEntries(template))` instead.
366
- */
367
- function createMapFromTemplate(template) {
368
- var map = new ts.Map();
369
- // Copies keys/values from template. Note that for..in will not throw if
370
- // template is undefined, and instead will just exit the loop.
371
- for (var key in template) {
372
- if (hasOwnProperty.call(template, key)) {
373
- map.set(key, template[key]);
374
- }
375
- }
376
- return map;
377
- }
378
- ts.createMapFromTemplate = createMapFromTemplate;
379
359
  function length(array) {
380
360
  return array ? array.length : 0;
381
361
  }
@@ -2610,11 +2590,6 @@ var ts;
2610
2590
  return value;
2611
2591
  }
2612
2592
  Debug.checkDefined = checkDefined;
2613
- /**
2614
- * @deprecated Use `checkDefined` to check whether a value is defined inline. Use `assertIsDefined` to check whether
2615
- * a value is defined at the statement level.
2616
- */
2617
- Debug.assertDefined = checkDefined;
2618
2593
  function assertEachIsDefined(value, message, stackCrawlMark) {
2619
2594
  for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
2620
2595
  var v = value_1[_i];
@@ -2627,11 +2602,6 @@ var ts;
2627
2602
  return value;
2628
2603
  }
2629
2604
  Debug.checkEachDefined = checkEachDefined;
2630
- /**
2631
- * @deprecated Use `checkEachDefined` to check whether the elements of an array are defined inline. Use `assertEachIsDefined` to check whether
2632
- * the elements of an array are defined at the statement level.
2633
- */
2634
- Debug.assertEachDefined = checkEachDefined;
2635
2605
  function assertNever(member, message, stackCrawlMark) {
2636
2606
  if (message === void 0) { message = "Illegal value:"; }
2637
2607
  var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
@@ -14091,21 +14061,6 @@ var ts;
14091
14061
  return undefined;
14092
14062
  }
14093
14063
  ts.getDeclarationOfKind = getDeclarationOfKind;
14094
- /**
14095
- * Create a new escaped identifier map.
14096
- * @deprecated Use `new Map<__String, T>()` instead.
14097
- */
14098
- function createUnderscoreEscapedMap() {
14099
- return new ts.Map();
14100
- }
14101
- ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap;
14102
- /**
14103
- * @deprecated Use `!!map?.size` instead
14104
- */
14105
- function hasEntries(map) {
14106
- return !!map && !!map.size;
14107
- }
14108
- ts.hasEntries = hasEntries;
14109
14064
  function createSymbolTable(symbols) {
14110
14065
  var result = new ts.Map();
14111
14066
  if (symbols) {
@@ -26698,7 +26653,7 @@ var ts;
26698
26653
  sourceMapText = mapTextOrStripInternal;
26699
26654
  }
26700
26655
  var node = oldFileOfCurrentEmit ?
26701
- parseOldFileOfCurrentEmit(ts.Debug.assertDefined(bundleFileInfo)) :
26656
+ parseOldFileOfCurrentEmit(ts.Debug.checkDefined(bundleFileInfo)) :
26702
26657
  parseUnparsedSourceFile(bundleFileInfo, stripInternal, length);
26703
26658
  node.fileName = fileName;
26704
26659
  node.sourceMapPath = sourceMapPath;
@@ -26845,13 +26800,13 @@ var ts;
26845
26800
  };
26846
26801
  node.javascriptPath = declarationTextOrJavascriptPath;
26847
26802
  node.javascriptMapPath = javascriptMapPath;
26848
- node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath);
26803
+ node.declarationPath = ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath);
26849
26804
  node.declarationMapPath = declarationMapPath;
26850
26805
  node.buildInfoPath = declarationMapTextOrBuildInfoPath;
26851
26806
  Object.defineProperties(node, {
26852
26807
  javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } },
26853
26808
  javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } },
26854
- declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } },
26809
+ declarationText: { get: function () { return definedTextGetter_1(ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } },
26855
26810
  declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } },
26856
26811
  buildInfo: { get: function () { return getAndCacheBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } }
26857
26812
  });
@@ -51860,8 +51815,8 @@ var ts;
51860
51815
  var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
51861
51816
  // If the expanded parameter list had a variadic in a non-trailing position, don't expand it
51862
51817
  var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 170 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
51863
- if (signature.thisParameter) {
51864
- var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
51818
+ var thisParameter = tryGetThisParameterDeclaration(signature, context);
51819
+ if (thisParameter) {
51865
51820
  parameters.unshift(thisParameter);
51866
51821
  }
51867
51822
  var returnTypeNode;
@@ -51910,6 +51865,21 @@ var ts;
51910
51865
  }
51911
51866
  return node;
51912
51867
  }
51868
+ function tryGetThisParameterDeclaration(signature, context) {
51869
+ if (signature.thisParameter) {
51870
+ return symbolToParameterDeclaration(signature.thisParameter, context);
51871
+ }
51872
+ if (signature.declaration) {
51873
+ var thisTag = ts.getJSDocThisTag(signature.declaration);
51874
+ if (thisTag && thisTag.typeExpression) {
51875
+ return ts.factory.createParameterDeclaration(
51876
+ /* decorators */ undefined,
51877
+ /* modifiers */ undefined,
51878
+ /* dotDotDotToken */ undefined, "this",
51879
+ /* questionToken */ undefined, typeToTypeNodeHelper(getTypeFromTypeNode(thisTag.typeExpression), context));
51880
+ }
51881
+ }
51882
+ }
51913
51883
  function typeParameterToDeclarationWithConstraint(type, context, constraintNode) {
51914
51884
  var savedContextFlags = context.flags;
51915
51885
  context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic
@@ -52351,10 +52321,8 @@ var ts;
52351
52321
  firstChar = symbolName.charCodeAt(0);
52352
52322
  }
52353
52323
  var expression = void 0;
52354
- if (ts.isSingleOrDoubleQuote(firstChar)) {
52355
- expression = ts.factory.createStringLiteral(symbolName
52356
- .substring(1, symbolName.length - 1)
52357
- .replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */);
52324
+ if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) {
52325
+ expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */);
52358
52326
  }
52359
52327
  else if (("" + +symbolName) === symbolName) {
52360
52328
  expression = ts.factory.createNumericLiteral(+symbolName);
@@ -94347,7 +94315,7 @@ var ts;
94347
94315
  function visitYieldExpression(node) {
94348
94316
  if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) {
94349
94317
  if (node.asteriskToken) {
94350
- var expression = ts.visitNode(ts.Debug.assertDefined(node.expression), visitor, ts.isExpression);
94318
+ var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression);
94351
94319
  return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
94352
94320
  /*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(factory.updateYieldExpression(node, node.asteriskToken, ts.setTextRange(emitHelpers().createAsyncDelegatorHelper(ts.setTextRange(emitHelpers().createAsyncValuesHelper(expression), expression)), expression)))), node), node);
94353
94321
  }
@@ -95272,11 +95240,11 @@ var ts;
95272
95240
  return existing.name;
95273
95241
  }
95274
95242
  if (!currentFileState.utilizedImplicitRuntimeImports) {
95275
- currentFileState.utilizedImplicitRuntimeImports = ts.createMap();
95243
+ currentFileState.utilizedImplicitRuntimeImports = new ts.Map();
95276
95244
  }
95277
95245
  var specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource);
95278
95246
  if (!specifierSourceImports) {
95279
- specifierSourceImports = ts.createMap();
95247
+ specifierSourceImports = new ts.Map();
95280
95248
  currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
95281
95249
  }
95282
95250
  var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */);
@@ -108871,6 +108839,7 @@ var ts;
108871
108839
  return emitJSDocSignature(node);
108872
108840
  case 325 /* JSDocTag */:
108873
108841
  case 330 /* JSDocClassTag */:
108842
+ case 335 /* JSDocOverrideTag */:
108874
108843
  return emitJSDocSimpleTag(node);
108875
108844
  case 326 /* JSDocAugmentsTag */:
108876
108845
  case 327 /* JSDocImplementsTag */:
@@ -108883,7 +108852,6 @@ var ts;
108883
108852
  case 332 /* JSDocPrivateTag */:
108884
108853
  case 333 /* JSDocProtectedTag */:
108885
108854
  case 334 /* JSDocReadonlyTag */:
108886
- case 335 /* JSDocOverrideTag */:
108887
108855
  return;
108888
108856
  case 336 /* JSDocCallbackTag */:
108889
108857
  return emitJSDocCallbackTag(node);
@@ -113803,6 +113771,24 @@ var ts;
113803
113771
  }
113804
113772
  }
113805
113773
  ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
113774
+ /** @internal */
113775
+ ts.plainJSErrors = new ts.Set([
113776
+ ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
113777
+ ts.Diagnostics.A_module_cannot_have_multiple_default_exports.code,
113778
+ ts.Diagnostics.Another_export_default_is_here.code,
113779
+ ts.Diagnostics.The_first_export_default_is_here.code,
113780
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module.code,
113781
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode.code,
113782
+ ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here.code,
113783
+ ts.Diagnostics.constructor_is_a_reserved_word.code,
113784
+ ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode.code,
113785
+ ts.Diagnostics.Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode.code,
113786
+ ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode.code,
113787
+ ts.Diagnostics.Invalid_use_of_0_in_strict_mode.code,
113788
+ ts.Diagnostics.A_label_is_not_allowed_here.code,
113789
+ ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode.code,
113790
+ ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode.code,
113791
+ ]);
113806
113792
  /**
113807
113793
  * Determine if source file needs to be re-created even if its text hasn't changed
113808
113794
  */
@@ -114463,6 +114449,7 @@ var ts;
114463
114449
  newSourceFile.originalFileName = oldSourceFile.originalFileName;
114464
114450
  newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
114465
114451
  newSourceFile.fileName = oldSourceFile.fileName;
114452
+ newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
114466
114453
  var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
114467
114454
  if (packageName !== undefined) {
114468
114455
  // If there are 2 different source files for the same package name and at least one of them changes,
@@ -114819,14 +114806,23 @@ var ts;
114819
114806
  }
114820
114807
  var typeChecker = getDiagnosticsProducingTypeChecker();
114821
114808
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
114822
- var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options);
114809
+ var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
114810
+ var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
114811
+ var isPlainJs = isJs && !sourceFile.checkJsDirective && options.checkJs === undefined;
114823
114812
  var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
114824
- // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins)
114813
+ // By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
114814
+ // - plain JS: .js files with no // ts-check and checkJs: undefined
114815
+ // - check JS: .js files with either // ts-check or checkJs: true
114816
+ // - external: files that are added by plugins
114825
114817
  var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */
114826
- || sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
114818
+ || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
114827
114819
  var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
114828
- var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
114829
- return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
114820
+ var checkDiagnostics = includeBindAndCheckDiagnostics && !isPlainJs ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
114821
+ if (isPlainJs) {
114822
+ bindDiagnostics = ts.filter(bindDiagnostics, function (d) { return ts.plainJSErrors.has(d.code); });
114823
+ }
114824
+ // skip ts-expect-error errors in plain JS files, and skip JSDoc errors except in checked JS
114825
+ return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics && !isPlainJs, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
114830
114826
  });
114831
114827
  }
114832
114828
  function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics) {
@@ -115840,7 +115836,7 @@ var ts;
115840
115836
  return resolvedRef;
115841
115837
  }
115842
115838
  function verifyCompilerOptions() {
115843
- var isNightly = ts.stringContains(ts.version, "-dev");
115839
+ var isNightly = ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
115844
115840
  if (!isNightly) {
115845
115841
  if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
115846
115842
  createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12");
@@ -118735,7 +118731,7 @@ var ts;
118735
118731
  function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
118736
118732
  if (resolution.refCount) {
118737
118733
  resolution.refCount++;
118738
- ts.Debug.assertDefined(resolution.files);
118734
+ ts.Debug.assertIsDefined(resolution.files);
118739
118735
  }
118740
118736
  else {
118741
118737
  resolution.refCount = 1;
@@ -118803,7 +118799,7 @@ var ts;
118803
118799
  }
118804
118800
  }
118805
118801
  function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
118806
- ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
118802
+ ts.unorderedRemoveItem(ts.Debug.checkDefined(resolution.files), filePath);
118807
118803
  resolution.refCount--;
118808
118804
  if (resolution.refCount) {
118809
118805
  return;
@@ -118895,7 +118891,7 @@ var ts;
118895
118891
  if (resolution.isInvalidated || !canInvalidate(resolution))
118896
118892
  continue;
118897
118893
  resolution.isInvalidated = invalidated = true;
118898
- for (var _a = 0, _b = ts.Debug.assertDefined(resolution.files); _a < _b.length; _a++) {
118894
+ for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
118899
118895
  var containingFilePath = _b[_a];
118900
118896
  (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
118901
118897
  // When its a file with inferred types resolution, invalidate type reference directive resolution
@@ -136171,14 +136167,17 @@ var ts;
136171
136167
  if (node === sourceFile) {
136172
136168
  return undefined;
136173
136169
  }
136174
- var symbol = typeChecker.getSymbolAtLocation(node);
136170
+ var symbol = getSymbol(node, typeChecker);
136175
136171
  if (!symbol)
136176
136172
  return undefined;
136177
136173
  var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
136178
136174
  var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
136179
136175
  var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
136180
136176
  // If a function returns 'void' or some other type with no definition, just return the function definition.
136181
- return fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
136177
+ var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
136178
+ return typeDefinitions.length ? typeDefinitions
136179
+ : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
136180
+ : undefined;
136182
136181
  }
136183
136182
  GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
136184
136183
  function definitionFromType(type, checker, node) {
@@ -145166,6 +145165,26 @@ var ts;
145166
145165
  var indent = sourceFile.text.slice(startPosition, fnStart);
145167
145166
  this.insertNodeAt(sourceFile, fnStart, tag, { preserveLeadingWhitespace: false, suffix: this.newLineCharacter + indent });
145168
145167
  };
145168
+ ChangeTracker.prototype.addJSDocTags = function (sourceFile, parent, newTags) {
145169
+ var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
145170
+ var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
145171
+ var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags.some(function (tag, i) {
145172
+ var merged = tryMergeJsdocTags(tag, newTag);
145173
+ if (merged)
145174
+ oldTags[i] = merged;
145175
+ return !!merged;
145176
+ }); });
145177
+ var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true)));
145178
+ var host = updateJSDocHost(parent);
145179
+ this.insertJsdocCommentBefore(sourceFile, host, tag);
145180
+ };
145181
+ ChangeTracker.prototype.filterJSDocTags = function (sourceFile, parent, predicate) {
145182
+ var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
145183
+ var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
145184
+ var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray([], (ts.filter(oldTags, predicate) || ts.emptyArray), true)));
145185
+ var host = updateJSDocHost(parent);
145186
+ this.insertJsdocCommentBefore(sourceFile, host, tag);
145187
+ };
145169
145188
  ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) {
145170
145189
  this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text });
145171
145190
  };
@@ -145560,6 +145579,33 @@ var ts;
145560
145579
  return ChangeTracker;
145561
145580
  }());
145562
145581
  textChanges_3.ChangeTracker = ChangeTracker;
145582
+ function updateJSDocHost(parent) {
145583
+ if (parent.kind !== 213 /* ArrowFunction */) {
145584
+ return parent;
145585
+ }
145586
+ var jsDocNode = parent.parent.kind === 166 /* PropertyDeclaration */ ?
145587
+ parent.parent :
145588
+ parent.parent.parent;
145589
+ jsDocNode.jsDoc = parent.jsDoc;
145590
+ jsDocNode.jsDocCache = parent.jsDocCache;
145591
+ return jsDocNode;
145592
+ }
145593
+ function tryMergeJsdocTags(oldTag, newTag) {
145594
+ if (oldTag.kind !== newTag.kind) {
145595
+ return undefined;
145596
+ }
145597
+ switch (oldTag.kind) {
145598
+ case 338 /* JSDocParameterTag */: {
145599
+ var oldParam = oldTag;
145600
+ var newParam = newTag;
145601
+ return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText
145602
+ ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment)
145603
+ : undefined;
145604
+ }
145605
+ case 339 /* JSDocReturnTag */:
145606
+ return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
145607
+ }
145608
+ }
145563
145609
  // find first non-whitespace position in the leading trivia of the node
145564
145610
  function startPositionToDeleteNodeInList(sourceFile, node) {
145565
145611
  return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
@@ -149808,35 +149854,72 @@ var ts;
149808
149854
  ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code,
149809
149855
  ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code,
149810
149856
  ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code,
149811
- ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code
149857
+ ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code,
149858
+ ts.Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code,
149859
+ ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class.code,
149860
+ ts.Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code,
149861
+ ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0.code,
149812
149862
  ];
149813
149863
  var errorCodeFixIdMap = (_a = {},
149814
- _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code] = [
149815
- ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers,
149816
- ],
149817
- _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code] = [
149818
- ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers
149819
- ],
149820
- _a[ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code] = [
149821
- ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers,
149822
- ],
149823
- _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code] = [
149824
- ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers
149825
- ],
149826
- _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code] = [
149827
- ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers
149828
- ],
149864
+ // case #1:
149865
+ _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code] = {
149866
+ descriptions: ts.Diagnostics.Add_override_modifier,
149867
+ fixId: fixAddOverrideId,
149868
+ fixAllDescriptions: ts.Diagnostics.Add_all_missing_override_modifiers,
149869
+ },
149870
+ _a[ts.Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code] = {
149871
+ descriptions: ts.Diagnostics.Add_override_modifier,
149872
+ fixId: fixAddOverrideId,
149873
+ fixAllDescriptions: ts.Diagnostics.Add_all_missing_override_modifiers
149874
+ },
149875
+ // case #2:
149876
+ _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code] = {
149877
+ descriptions: ts.Diagnostics.Remove_override_modifier,
149878
+ fixId: fixRemoveOverrideId,
149879
+ fixAllDescriptions: ts.Diagnostics.Remove_all_unnecessary_override_modifiers,
149880
+ },
149881
+ _a[ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class.code] = {
149882
+ descriptions: ts.Diagnostics.Remove_override_modifier,
149883
+ fixId: fixRemoveOverrideId,
149884
+ fixAllDescriptions: ts.Diagnostics.Remove_override_modifier
149885
+ },
149886
+ // case #3:
149887
+ _a[ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code] = {
149888
+ descriptions: ts.Diagnostics.Add_override_modifier,
149889
+ fixId: fixAddOverrideId,
149890
+ fixAllDescriptions: ts.Diagnostics.Add_all_missing_override_modifiers,
149891
+ },
149892
+ _a[ts.Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code] = {
149893
+ descriptions: ts.Diagnostics.Add_override_modifier,
149894
+ fixId: fixAddOverrideId,
149895
+ fixAllDescriptions: ts.Diagnostics.Add_all_missing_override_modifiers,
149896
+ },
149897
+ // case #4:
149898
+ _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code] = {
149899
+ descriptions: ts.Diagnostics.Add_override_modifier,
149900
+ fixId: fixAddOverrideId,
149901
+ fixAllDescriptions: ts.Diagnostics.Remove_all_unnecessary_override_modifiers,
149902
+ },
149903
+ // case #5:
149904
+ _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code] = {
149905
+ descriptions: ts.Diagnostics.Remove_override_modifier,
149906
+ fixId: fixRemoveOverrideId,
149907
+ fixAllDescriptions: ts.Diagnostics.Remove_all_unnecessary_override_modifiers,
149908
+ },
149909
+ _a[ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0.code] = {
149910
+ descriptions: ts.Diagnostics.Remove_override_modifier,
149911
+ fixId: fixRemoveOverrideId,
149912
+ fixAllDescriptions: ts.Diagnostics.Remove_all_unnecessary_override_modifiers,
149913
+ },
149829
149914
  _a);
149830
149915
  codefix.registerCodeFix({
149831
149916
  errorCodes: errorCodes,
149832
149917
  getCodeActions: function (context) {
149833
- var errorCode = context.errorCode, span = context.span, sourceFile = context.sourceFile;
149918
+ var errorCode = context.errorCode, span = context.span;
149834
149919
  var info = errorCodeFixIdMap[errorCode];
149835
149920
  if (!info)
149836
149921
  return ts.emptyArray;
149837
- var descriptions = info[0], fixId = info[1], fixAllDescriptions = info[2];
149838
- if (ts.isSourceFileJS(sourceFile))
149839
- return ts.emptyArray;
149922
+ var descriptions = info.descriptions, fixId = info.fixId, fixAllDescriptions = info.fixAllDescriptions;
149840
149923
  var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { return dispatchChanges(changes, context, errorCode, span.start); });
149841
149924
  return [
149842
149925
  codefix.createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId, fixAllDescriptions)
@@ -149845,9 +149928,9 @@ var ts;
149845
149928
  fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
149846
149929
  getAllCodeActions: function (context) {
149847
149930
  return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
149848
- var code = diag.code, start = diag.start, file = diag.file;
149931
+ var code = diag.code, start = diag.start;
149849
149932
  var info = errorCodeFixIdMap[code];
149850
- if (!info || info[1] !== context.fixId || ts.isSourceFileJS(file)) {
149933
+ if (!info || info.fixId !== context.fixId) {
149851
149934
  return;
149852
149935
  }
149853
149936
  dispatchChanges(changes, context, code, start);
@@ -149857,11 +149940,15 @@ var ts;
149857
149940
  function dispatchChanges(changeTracker, context, errorCode, pos) {
149858
149941
  switch (errorCode) {
149859
149942
  case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code:
149943
+ case ts.Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code:
149860
149944
  case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code:
149861
149945
  case ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code:
149946
+ case ts.Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0.code:
149862
149947
  return doAddOverrideModifierChange(changeTracker, context.sourceFile, pos);
149863
149948
  case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code:
149949
+ case ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0.code:
149864
149950
  case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code:
149951
+ case ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class.code:
149865
149952
  return doRemoveOverrideModifierChange(changeTracker, context.sourceFile, pos);
149866
149953
  default:
149867
149954
  ts.Debug.fail("Unexpected error code: " + errorCode);
@@ -149869,6 +149956,10 @@ var ts;
149869
149956
  }
149870
149957
  function doAddOverrideModifierChange(changeTracker, sourceFile, pos) {
149871
149958
  var classElement = findContainerClassElementLike(sourceFile, pos);
149959
+ if (ts.isSourceFileJS(sourceFile)) {
149960
+ changeTracker.addJSDocTags(sourceFile, classElement, [ts.factory.createJSDocOverrideTag(ts.factory.createIdentifier("override"))]);
149961
+ return;
149962
+ }
149872
149963
  var modifiers = classElement.modifiers || ts.emptyArray;
149873
149964
  var staticModifier = ts.find(modifiers, ts.isStaticModifier);
149874
149965
  var abstractModifier = ts.find(modifiers, ts.isAbstractModifier);
@@ -149882,6 +149973,10 @@ var ts;
149882
149973
  }
149883
149974
  function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) {
149884
149975
  var classElement = findContainerClassElementLike(sourceFile, pos);
149976
+ if (ts.isSourceFileJS(sourceFile)) {
149977
+ changeTracker.filterJSDocTags(sourceFile, classElement, ts.not(ts.isJSDocOverrideTag));
149978
+ return;
149979
+ }
149885
149980
  var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 158 /* OverrideKeyword */; });
149886
149981
  ts.Debug.assertIsDefined(overrideModifier);
149887
149982
  changeTracker.deleteModifier(sourceFile, overrideModifier);
@@ -149975,9 +150070,9 @@ var ts;
149975
150070
  if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn))
149976
150071
  return undefined;
149977
150072
  if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function
149978
- var fnKeyword = ts.Debug.assertDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile));
150073
+ var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile));
149979
150074
  var name = fn.name;
149980
- var body = ts.Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression
150075
+ var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression
149981
150076
  if (ts.isFunctionExpression(fn)) {
149982
150077
  if (name && ts.FindAllReferences.Core.isSymbolReferencedInFile(name, checker, sourceFile, body)) {
149983
150078
  // Function expression references itself. To fix we would have to extract it to a const.
@@ -152245,7 +152340,7 @@ var ts;
152245
152340
  if (typeNode) {
152246
152341
  // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags
152247
152342
  var typeTag = ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode), /*comment*/ undefined);
152248
- addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]);
152343
+ changes.addJSDocTags(sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]);
152249
152344
  }
152250
152345
  importAdder.writeFixes(changes);
152251
152346
  return parent;
@@ -152356,7 +152451,7 @@ var ts;
152356
152451
  }
152357
152452
  }
152358
152453
  function annotateJSDocThis(changes, sourceFile, containingFunction, typeNode) {
152359
- addJSDocTags(changes, sourceFile, containingFunction, [
152454
+ changes.addJSDocTags(sourceFile, containingFunction, [
152360
152455
  ts.factory.createJSDocThisTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode)),
152361
152456
  ]);
152362
152457
  }
@@ -152385,7 +152480,7 @@ var ts;
152385
152480
  }
152386
152481
  var typeExpression = ts.factory.createJSDocTypeExpression(typeNode);
152387
152482
  var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined) : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined);
152388
- addJSDocTags(changes, sourceFile, parent, [typeTag]);
152483
+ changes.addJSDocTags(sourceFile, parent, [typeTag]);
152389
152484
  }
152390
152485
  else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, ts.getEmitScriptTarget(program.getCompilerOptions()))) {
152391
152486
  changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode);
@@ -152441,45 +152536,7 @@ var ts;
152441
152536
  var name = _a.name, typeNode = _a.typeNode, isOptional = _a.isOptional;
152442
152537
  return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, ts.factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, /*comment*/ undefined);
152443
152538
  });
152444
- addJSDocTags(changes, sourceFile, signature, paramTags);
152445
- }
152446
- }
152447
- function addJSDocTags(changes, sourceFile, parent, newTags) {
152448
- var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; });
152449
- var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; });
152450
- var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) {
152451
- var merged = tryMergeJsdocTags(tag, newTag);
152452
- if (merged)
152453
- oldTags[i] = merged;
152454
- return !!merged;
152455
- }); });
152456
- var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray), true), unmergedNewTags, true)));
152457
- var jsDocNode = parent.kind === 213 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent;
152458
- jsDocNode.jsDoc = parent.jsDoc;
152459
- jsDocNode.jsDocCache = parent.jsDocCache;
152460
- changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag);
152461
- }
152462
- codefix.addJSDocTags = addJSDocTags;
152463
- function getJsDocNodeForArrowFunction(signature) {
152464
- if (signature.parent.kind === 166 /* PropertyDeclaration */) {
152465
- return signature.parent;
152466
- }
152467
- return signature.parent.parent;
152468
- }
152469
- function tryMergeJsdocTags(oldTag, newTag) {
152470
- if (oldTag.kind !== newTag.kind) {
152471
- return undefined;
152472
- }
152473
- switch (oldTag.kind) {
152474
- case 338 /* JSDocParameterTag */: {
152475
- var oldParam = oldTag;
152476
- var newParam = newTag;
152477
- return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText
152478
- ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment)
152479
- : undefined;
152480
- }
152481
- case 339 /* JSDocReturnTag */:
152482
- return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
152539
+ changes.addJSDocTags(sourceFile, signature, paramTags);
152483
152540
  }
152484
152541
  }
152485
152542
  function getReferences(token, program, cancellationToken) {
@@ -166044,15 +166101,15 @@ var ts;
166044
166101
  if (!resolution.resolvedFileName)
166045
166102
  continue;
166046
166103
  var resolvedFileName = resolution.resolvedFileName, originalPath = resolution.originalPath;
166104
+ if (originalPath) {
166105
+ symlinkCache.setSymlinkedDirectoryFromSymlinkedFile(originalPath, resolvedFileName);
166106
+ }
166047
166107
  if (!program.getSourceFile(resolvedFileName) && (!originalPath || !program.getSourceFile(originalPath))) {
166048
166108
  rootNames = ts.append(rootNames, resolvedFileName);
166049
166109
  // Avoid creating a large project that would significantly slow down time to editor interactivity
166050
166110
  if (dependencySelection === 2 /* Auto */ && rootNames.length > this.maxDependencies) {
166051
166111
  return ts.emptyArray;
166052
166112
  }
166053
- if (originalPath) {
166054
- symlinkCache.setSymlinkedDirectoryFromSymlinkedFile(originalPath, resolvedFileName);
166055
- }
166056
166113
  }
166057
166114
  }
166058
166115
  }
@@ -172053,7 +172110,7 @@ var ts;
172053
172110
  Session.prototype.getFullNavigateToItems = function (args) {
172054
172111
  var currentFileOnly = args.currentFileOnly, searchValue = args.searchValue, maxResultCount = args.maxResultCount, projectFileName = args.projectFileName;
172055
172112
  if (currentFileOnly) {
172056
- ts.Debug.assertDefined(args.file);
172113
+ ts.Debug.assertIsDefined(args.file);
172057
172114
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
172058
172115
  return [{ project: project, result: project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file) }];
172059
172116
  }