typescript 4.8.0-dev.20220807 → 4.9.0-dev.20220811

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -105,11 +105,11 @@ var ts;
105
105
  (function (ts) {
106
106
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
107
107
  // If changing the text in this section, be sure to test `configurePrerelease` too.
108
- ts.versionMajorMinor = "4.8";
108
+ ts.versionMajorMinor = "4.9";
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-dev.20220807";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220811";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -131,7 +131,11 @@ var ts;
131
131
  // Internet Explorer's Map doesn't support iteration, so don't use it.
132
132
  var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
133
133
  // eslint-disable-next-line no-in-operator
134
- return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
134
+ var constructor = typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
135
+ if (!constructor) {
136
+ throw new Error("No compatible Map implementation found.");
137
+ }
138
+ return constructor;
135
139
  }
136
140
  NativeCollections.tryGetNativeMap = tryGetNativeMap;
137
141
  /**
@@ -141,23 +145,18 @@ var ts;
141
145
  // Internet Explorer's Set doesn't support iteration, so don't use it.
142
146
  var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
143
147
  // eslint-disable-next-line no-in-operator
144
- return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
148
+ var constructor = typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
149
+ if (!constructor) {
150
+ throw new Error("No compatible Set implementation found.");
151
+ }
152
+ return constructor;
145
153
  }
146
154
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
147
155
  })(NativeCollections || (NativeCollections = {}));
148
156
  /* @internal */
149
- ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
157
+ ts.Map = NativeCollections.tryGetNativeMap();
150
158
  /* @internal */
151
- ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
152
- /* @internal */
153
- function getCollectionImplementation(name, nativeFactory, shimFactory) {
154
- var _a;
155
- // NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it.
156
- var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator);
157
- if (constructor)
158
- return constructor;
159
- throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");
160
- }
159
+ ts.Set = NativeCollections.tryGetNativeSet();
161
160
  })(ts || (ts = {}));
162
161
  /* @internal */
163
162
  var ts;
@@ -873,15 +872,18 @@ var ts;
873
872
  function insertSorted(array, insert, compare, allowDuplicates) {
874
873
  if (array.length === 0) {
875
874
  array.push(insert);
876
- return;
875
+ return true;
877
876
  }
878
877
  var insertIndex = binarySearch(array, insert, identity, compare);
879
878
  if (insertIndex < 0) {
880
879
  array.splice(~insertIndex, 0, insert);
880
+ return true;
881
881
  }
882
- else if (allowDuplicates) {
882
+ if (allowDuplicates) {
883
883
  array.splice(insertIndex, 0, insert);
884
+ return true;
884
885
  }
886
+ return false;
885
887
  }
886
888
  ts.insertSorted = insertSorted;
887
889
  function sortAndDeduplicate(array, comparer, equalityComparer) {
@@ -7842,12 +7844,9 @@ var ts;
7842
7844
  * Normalize path separators, converting `\` into `/`.
7843
7845
  */
7844
7846
  function normalizeSlashes(path) {
7845
- var index = path.indexOf("\\");
7846
- if (index === -1) {
7847
- return path;
7848
- }
7849
- backslashRegExp.lastIndex = index; // prime regex with known position
7850
- return path.replace(backslashRegExp, ts.directorySeparator);
7847
+ return path.indexOf("\\") !== -1
7848
+ ? path.replace(backslashRegExp, ts.directorySeparator)
7849
+ : path;
7851
7850
  }
7852
7851
  ts.normalizeSlashes = normalizeSlashes;
7853
7852
  /**
@@ -9548,6 +9547,7 @@ var ts;
9548
9547
  Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."),
9549
9548
  Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted: diag(6399, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitte_6399", "Project '{0}' is out of date because buildinfo file '{1}' indicates that some of the changes were not emitted"),
9550
9549
  Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files: diag(6400, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_fil_6400", "Project '{0}' is up to date but needs to update timestamps of output files that are older than input files"),
9550
+ Project_0_is_out_of_date_because_there_was_error_reading_file_1: diag(6401, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_there_was_error_reading_file_1_6401", "Project '{0}' is out of date because there was error reading file '{1}'"),
9551
9551
  The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
9552
9552
  The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
9553
9553
  The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
@@ -19391,21 +19391,17 @@ var ts;
19391
19391
  return getStringFromExpandedCharCodes(expandedCharCodes);
19392
19392
  }
19393
19393
  ts.base64decode = base64decode;
19394
+ function readJsonOrUndefined(path, hostOrText) {
19395
+ var jsonText = ts.isString(hostOrText) ? hostOrText : hostOrText.readFile(path);
19396
+ if (!jsonText)
19397
+ return undefined;
19398
+ // gracefully handle if readFile fails or returns not JSON
19399
+ var result = ts.parseConfigFileTextToJson(path, jsonText);
19400
+ return !result.error ? result.config : undefined;
19401
+ }
19402
+ ts.readJsonOrUndefined = readJsonOrUndefined;
19394
19403
  function readJson(path, host) {
19395
- try {
19396
- var jsonText = host.readFile(path);
19397
- if (!jsonText)
19398
- return {};
19399
- var result = ts.parseConfigFileTextToJson(path, jsonText);
19400
- if (result.error) {
19401
- return {};
19402
- }
19403
- return result.config;
19404
- }
19405
- catch (e) {
19406
- // gracefully handle if readFile fails or returns not JSON
19407
- return {};
19408
- }
19404
+ return readJsonOrUndefined(path, host) || {};
19409
19405
  }
19410
19406
  ts.readJson = readJson;
19411
19407
  function directoryProbablyExists(directoryName, host) {
@@ -27756,9 +27752,10 @@ var ts;
27756
27752
  };
27757
27753
  var buildInfo_1;
27758
27754
  var getAndCacheBuildInfo_1 = function (getText) {
27755
+ var _a;
27759
27756
  if (buildInfo_1 === undefined) {
27760
27757
  var result = getText();
27761
- buildInfo_1 = result !== undefined ? ts.getBuildInfo(result) : false;
27758
+ buildInfo_1 = result !== undefined ? (_a = ts.getBuildInfo(node.buildInfoPath, result)) !== null && _a !== void 0 ? _a : false : false;
27762
27759
  }
27763
27760
  return buildInfo_1 || undefined;
27764
27761
  };
@@ -45818,6 +45815,9 @@ var ts;
45818
45815
  case 203 /* BindingElement */:
45819
45816
  bindBindingElementFlow(node);
45820
45817
  break;
45818
+ case 164 /* Parameter */:
45819
+ bindParameterFlow(node);
45820
+ break;
45821
45821
  case 205 /* ObjectLiteralExpression */:
45822
45822
  case 204 /* ArrayLiteralExpression */:
45823
45823
  case 296 /* PropertyAssignment */:
@@ -46558,20 +46558,38 @@ var ts;
46558
46558
  }
46559
46559
  }
46560
46560
  function bindBindingElementFlow(node) {
46561
- if (ts.isBindingPattern(node.name)) {
46562
- // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46563
- // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46564
- // - `BindingElement: BindingPattern Initializer?`
46565
- // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46566
- // - `BindingElement: BindingPattern Initializer?`
46567
- bind(node.dotDotDotToken);
46568
- bind(node.propertyName);
46569
- bind(node.initializer);
46570
- bind(node.name);
46561
+ // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46562
+ // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46563
+ // - `BindingElement: BindingPattern Initializer?`
46564
+ // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46565
+ // - `BindingElement: BindingPattern Initializer?`
46566
+ bind(node.dotDotDotToken);
46567
+ bind(node.propertyName);
46568
+ bindInitializer(node.initializer);
46569
+ bind(node.name);
46570
+ }
46571
+ function bindParameterFlow(node) {
46572
+ bindEach(node.modifiers);
46573
+ bind(node.dotDotDotToken);
46574
+ bind(node.questionToken);
46575
+ bind(node.type);
46576
+ bindInitializer(node.initializer);
46577
+ bind(node.name);
46578
+ }
46579
+ // a BindingElement/Parameter does not have side effects if initializers are not evaluated and used. (see GH#49759)
46580
+ function bindInitializer(node) {
46581
+ if (!node) {
46582
+ return;
46571
46583
  }
46572
- else {
46573
- bindEachChild(node);
46584
+ var entryFlow = currentFlow;
46585
+ bind(node);
46586
+ if (entryFlow === unreachableFlow || entryFlow === currentFlow) {
46587
+ return;
46574
46588
  }
46589
+ var exitFlow = createBranchLabel();
46590
+ addAntecedent(exitFlow, entryFlow);
46591
+ addAntecedent(exitFlow, currentFlow);
46592
+ currentFlow = finishFlowLabel(exitFlow);
46575
46593
  }
46576
46594
  function bindJSDocTypeAlias(node) {
46577
46595
  bind(node.tagName);
@@ -49742,7 +49760,7 @@ var ts;
49742
49760
  if (unidirectional === void 0) { unidirectional = false; }
49743
49761
  source.forEach(function (sourceSymbol, id) {
49744
49762
  var targetSymbol = target.get(id);
49745
- target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
49763
+ target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : getMergedSymbol(sourceSymbol));
49746
49764
  });
49747
49765
  }
49748
49766
  function mergeModuleAugmentation(moduleName) {
@@ -56533,11 +56551,9 @@ var ts;
56533
56551
  return getReturnTypeOfSignature(getterSignature);
56534
56552
  }
56535
56553
  }
56536
- if (ts.isInJSFile(declaration)) {
56537
- var type_1 = getParameterTypeOfTypeTag(func, declaration);
56538
- if (type_1)
56539
- return type_1;
56540
- }
56554
+ var parameterTypeOfTypeTag = getParameterTypeOfTypeTag(func, declaration);
56555
+ if (parameterTypeOfTypeTag)
56556
+ return parameterTypeOfTypeTag;
56541
56557
  // Use contextual parameter type if one is available
56542
56558
  var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
56543
56559
  if (type) {
@@ -57113,9 +57129,9 @@ var ts;
57113
57129
  if (typeNode === undefined) {
57114
57130
  return useUnknownInCatchVariables ? unknownType : anyType;
57115
57131
  }
57116
- var type_2 = getTypeOfNode(typeNode);
57132
+ var type_1 = getTypeOfNode(typeNode);
57117
57133
  // an errorType will make `checkTryStatement` issue an error
57118
- return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
57134
+ return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
57119
57135
  }
57120
57136
  // Handle export default expressions
57121
57137
  if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
@@ -57325,11 +57341,11 @@ var ts;
57325
57341
  return errorType;
57326
57342
  }
57327
57343
  var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
57328
- var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57344
+ var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57329
57345
  if (!popTypeResolution()) {
57330
57346
  return reportCircularityError(symbol);
57331
57347
  }
57332
- return type_3;
57348
+ return type_2;
57333
57349
  }
57334
57350
  }
57335
57351
  var type = createObjectType(16 /* Anonymous */, symbol);
@@ -59552,10 +59568,10 @@ var ts;
59552
59568
  var baseTypes = [];
59553
59569
  var different = false;
59554
59570
  for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
59555
- var type_4 = types_7[_i];
59556
- var baseType = getBaseConstraint(type_4);
59571
+ var type_3 = types_7[_i];
59572
+ var baseType = getBaseConstraint(type_3);
59557
59573
  if (baseType) {
59558
- if (baseType !== type_4) {
59574
+ if (baseType !== type_3) {
59559
59575
  different = true;
59560
59576
  }
59561
59577
  baseTypes.push(baseType);
@@ -60346,7 +60362,12 @@ var ts;
60346
60362
  continue;
60347
60363
  }
60348
60364
  }
60349
- result.push(getSignatureFromDeclaration(decl));
60365
+ // If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters.
60366
+ // Exclude contextually-typed kinds because we already apply the @type tag to the context, plus applying it here to the initializer would supress checks that the two are compatible.
60367
+ result.push((!ts.isFunctionExpressionOrArrowFunction(decl) &&
60368
+ !ts.isObjectLiteralMethod(decl) &&
60369
+ getSignatureOfTypeTag(decl)) ||
60370
+ getSignatureFromDeclaration(decl));
60350
60371
  }
60351
60372
  return result;
60352
60373
  }
@@ -60377,7 +60398,7 @@ var ts;
60377
60398
  else {
60378
60399
  var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
60379
60400
  var jsdocPredicate = void 0;
60380
- if (!type && ts.isInJSFile(signature.declaration)) {
60401
+ if (!type) {
60381
60402
  var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
60382
60403
  if (jsdocSignature && signature !== jsdocSignature) {
60383
60404
  jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
@@ -64403,15 +64424,14 @@ var ts;
64403
64424
  return false;
64404
64425
  }
64405
64426
  function isContextSensitiveFunctionLikeDeclaration(node) {
64406
- return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
64407
- (ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
64427
+ return ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node);
64408
64428
  }
64409
64429
  function hasContextSensitiveReturnExpression(node) {
64410
64430
  // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value.
64411
64431
  return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body);
64412
64432
  }
64413
64433
  function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
64414
- return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64434
+ return (ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64415
64435
  isContextSensitiveFunctionLikeDeclaration(func);
64416
64436
  }
64417
64437
  function getTypeWithoutSignatures(type) {
@@ -73469,9 +73489,11 @@ var ts;
73469
73489
  case 1 /* ExportsProperty */:
73470
73490
  case 6 /* Prototype */:
73471
73491
  case 3 /* PrototypeProperty */:
73472
- var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
73473
- // falls through
73474
73492
  case 2 /* ModuleExports */:
73493
+ var valueDeclaration = void 0;
73494
+ if (kind !== 2 /* ModuleExports */) {
73495
+ valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
73496
+ }
73475
73497
  valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration);
73476
73498
  var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration);
73477
73499
  return annotated ? getTypeFromTypeNode(annotated) : undefined;
@@ -73949,9 +73971,18 @@ var ts;
73949
73971
  if (!isErrorType(intrinsicClassAttribs)) {
73950
73972
  var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
73951
73973
  var hostClassType = getReturnTypeOfSignature(sig);
73952
- apparentAttributesType = intersectTypes(typeParams
73953
- ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
73954
- : intrinsicClassAttribs, apparentAttributesType);
73974
+ var libraryManagedAttributeType = void 0;
73975
+ if (typeParams && typeParams.length === 1) {
73976
+ var inferredArgs = fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context));
73977
+ libraryManagedAttributeType = instantiateType(intrinsicClassAttribs, createTypeMapper(typeParams, inferredArgs));
73978
+ }
73979
+ else if (typeParams)
73980
+ libraryManagedAttributeType = undefined;
73981
+ else
73982
+ libraryManagedAttributeType = intrinsicClassAttribs;
73983
+ if (libraryManagedAttributeType) {
73984
+ apparentAttributesType = intersectTypes(libraryManagedAttributeType, apparentAttributesType);
73985
+ }
73955
73986
  }
73956
73987
  var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
73957
73988
  if (!isErrorType(intrinsicAttribs)) {
@@ -74456,16 +74487,30 @@ var ts;
74456
74487
  // If object literal is contextually typed by the implied type of a binding pattern, augment the result
74457
74488
  // type with those properties for which the binding pattern specifies a default value.
74458
74489
  // If the object literal is spread into another object literal, skip this step and let the top-level object
74459
- // literal handle it instead.
74460
- if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) {
74461
- for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74462
- var prop = _e[_d];
74463
- if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74464
- if (!(prop.flags & 16777216 /* Optional */)) {
74465
- error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74490
+ // literal handle it instead. Note that this might require full traversal to the root pattern's parent
74491
+ // as it's the guaranteed to be the common ancestor of the pattern node and the current object node.
74492
+ // It's not possible to check if the immediate parent node is a spread assignment
74493
+ // since the type flows in non-obvious ways through conditional expressions, IIFEs and more.
74494
+ if (contextualTypeHasPattern) {
74495
+ var rootPatternParent_1 = ts.findAncestor(contextualType.pattern.parent, function (n) {
74496
+ return n.kind === 254 /* VariableDeclaration */ ||
74497
+ n.kind === 221 /* BinaryExpression */ ||
74498
+ n.kind === 164 /* Parameter */;
74499
+ });
74500
+ var spreadOrOutsideRootObject = ts.findAncestor(node, function (n) {
74501
+ return n === rootPatternParent_1 ||
74502
+ n.kind === 298 /* SpreadAssignment */;
74503
+ });
74504
+ if (spreadOrOutsideRootObject.kind !== 298 /* SpreadAssignment */) {
74505
+ for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74506
+ var prop = _e[_d];
74507
+ if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74508
+ if (!(prop.flags & 16777216 /* Optional */)) {
74509
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74510
+ }
74511
+ propertiesTable.set(prop.escapedName, prop);
74512
+ propertiesArray.push(prop);
74466
74513
  }
74467
- propertiesTable.set(prop.escapedName, prop);
74468
- propertiesArray.push(prop);
74469
74514
  }
74470
74515
  }
74471
74516
  }
@@ -77764,12 +77809,15 @@ var ts;
77764
77809
  return false;
77765
77810
  }
77766
77811
  var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
77767
- ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
77812
+ (ts.isVariableDeclaration(node) || ts.isPropertyAssignment(node)) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
77768
77813
  undefined;
77769
77814
  if (func) {
77770
- // If the node has a @class tag, treat it like a constructor.
77815
+ // If the node has a @class or @constructor tag, treat it like a constructor.
77771
77816
  if (ts.getJSDocClassTag(node))
77772
77817
  return true;
77818
+ // If the node is a property of an object literal.
77819
+ if (ts.isPropertyAssignment(ts.walkUpParenthesizedExpressions(func.parent)))
77820
+ return false;
77773
77821
  // If the symbol of the node has members, treat it like a constructor.
77774
77822
  var symbol = getSymbolOfNode(func);
77775
77823
  return !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.members) === null || _a === void 0 ? void 0 : _a.size);
@@ -78017,8 +78065,8 @@ var ts;
78017
78065
  if (hasDefaultOnly && type && !isErrorType(type)) {
78018
78066
  var synthType = type;
78019
78067
  if (!synthType.defaultOnlyType) {
78020
- var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78021
- synthType.defaultOnlyType = type_5;
78068
+ var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78069
+ synthType.defaultOnlyType = type_4;
78022
78070
  }
78023
78071
  return synthType.defaultOnlyType;
78024
78072
  }
@@ -87355,6 +87403,12 @@ var ts;
87355
87403
  return resolveJSDocMemberName(name, /*ignoreErrors*/ false, getSymbolOfNode(container));
87356
87404
  }
87357
87405
  }
87406
+ if (result && isJSDoc_1) {
87407
+ var container = ts.getJSDocHost(name);
87408
+ if (container && ts.isEnumMember(container) && container === result.valueDeclaration) {
87409
+ return resolveEntityName(name, meaning, /*ignoreErrors*/ true, /* dontResolveAlias */ true, ts.getSourceFileOfNode(container)) || result;
87410
+ }
87411
+ }
87358
87412
  return result;
87359
87413
  }
87360
87414
  else if (ts.isPrivateIdentifier(name)) {
@@ -107516,6 +107570,13 @@ var ts;
107516
107570
  ts.Debug.assert(importVariableName !== undefined);
107517
107571
  // save import into the local
107518
107572
  statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
107573
+ if (ts.hasSyntacticModifier(entry, 1 /* Export */)) {
107574
+ statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction,
107575
+ /*typeArguments*/ undefined, [
107576
+ factory.createStringLiteral(ts.idText(importVariableName)),
107577
+ parameterName,
107578
+ ])));
107579
+ }
107519
107580
  break;
107520
107581
  case 272 /* ExportDeclaration */:
107521
107582
  ts.Debug.assert(importVariableName !== undefined);
@@ -110358,8 +110419,12 @@ var ts;
110358
110419
  }
110359
110420
  var previousNeedsDeclare = needsDeclare;
110360
110421
  switch (input.kind) {
110361
- case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all
110362
- return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110422
+ case 259 /* TypeAliasDeclaration */: {
110423
+ needsDeclare = false;
110424
+ var clean = cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110425
+ needsDeclare = previousNeedsDeclare;
110426
+ return clean;
110427
+ }
110363
110428
  case 258 /* InterfaceDeclaration */: {
110364
110429
  return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
110365
110430
  }
@@ -111863,8 +111928,8 @@ var ts;
111863
111928
  }
111864
111929
  ts.getBuildInfoText = getBuildInfoText;
111865
111930
  /*@internal*/
111866
- function getBuildInfo(buildInfoText) {
111867
- return JSON.parse(buildInfoText);
111931
+ function getBuildInfo(buildInfoFile, buildInfoText) {
111932
+ return ts.readJsonOrUndefined(buildInfoFile, buildInfoText);
111868
111933
  }
111869
111934
  ts.getBuildInfo = getBuildInfo;
111870
111935
  /*@internal*/
@@ -111942,17 +112007,16 @@ var ts;
111942
112007
  var buildInfo;
111943
112008
  if (host.getBuildInfo) {
111944
112009
  // If host directly provides buildinfo we can get it directly. This allows host to cache the buildinfo
111945
- var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
111946
- if (!hostBuildInfo)
111947
- return buildInfoPath;
111948
- buildInfo = hostBuildInfo;
112010
+ buildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
111949
112011
  }
111950
112012
  else {
111951
112013
  var buildInfoText = host.readFile(buildInfoPath);
111952
112014
  if (!buildInfoText)
111953
112015
  return buildInfoPath;
111954
- buildInfo = getBuildInfo(buildInfoText);
112016
+ buildInfo = getBuildInfo(buildInfoPath, buildInfoText);
111955
112017
  }
112018
+ if (!buildInfo)
112019
+ return buildInfoPath;
111956
112020
  if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
111957
112021
  return buildInfoPath;
111958
112022
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
@@ -116610,7 +116674,16 @@ var ts;
116610
116674
  return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
116611
116675
  }
116612
116676
  function getCachedFileSystemEntriesForBaseDir(path) {
116613
- return getCachedFileSystemEntries(ts.getDirectoryPath(path));
116677
+ var entries = getCachedFileSystemEntries(ts.getDirectoryPath(path));
116678
+ if (!entries) {
116679
+ return entries;
116680
+ }
116681
+ // If we're looking for the base directory, we're definitely going to search the entries
116682
+ if (!entries.sortedAndCanonicalizedFiles) {
116683
+ entries.sortedAndCanonicalizedFiles = entries.files.map(getCanonicalFileName).sort();
116684
+ entries.sortedAndCanonicalizedDirectories = entries.directories.map(getCanonicalFileName).sort();
116685
+ }
116686
+ return entries;
116614
116687
  }
116615
116688
  function getBaseNameOfFileName(fileName) {
116616
116689
  return ts.getBaseFileName(ts.normalizePath(fileName));
@@ -116653,21 +116726,10 @@ var ts;
116653
116726
  return undefined;
116654
116727
  }
116655
116728
  }
116656
- function fileNameEqual(name1, name2) {
116657
- return getCanonicalFileName(name1) === getCanonicalFileName(name2);
116658
- }
116659
116729
  function hasEntry(entries, name) {
116660
- return ts.some(entries, function (file) { return fileNameEqual(file, name); });
116661
- }
116662
- function updateFileSystemEntry(entries, baseName, isValid) {
116663
- if (hasEntry(entries, baseName)) {
116664
- if (!isValid) {
116665
- return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
116666
- }
116667
- }
116668
- else if (isValid) {
116669
- return entries.push(baseName);
116670
- }
116730
+ // Case-sensitive comparison since already canonicalized
116731
+ var index = ts.binarySearch(entries, name, ts.identity, ts.compareStringsCaseSensitive);
116732
+ return index >= 0;
116671
116733
  }
116672
116734
  function writeFile(fileName, data, writeByteOrderMark) {
116673
116735
  var path = toPath(fileName);
@@ -116680,7 +116742,7 @@ var ts;
116680
116742
  function fileExists(fileName) {
116681
116743
  var path = toPath(fileName);
116682
116744
  var result = getCachedFileSystemEntriesForBaseDir(path);
116683
- return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
116745
+ return result && hasEntry(result.sortedAndCanonicalizedFiles, getCanonicalFileName(getBaseNameOfFileName(fileName))) ||
116684
116746
  host.fileExists(fileName);
116685
116747
  }
116686
116748
  function directoryExists(dirPath) {
@@ -116690,9 +116752,14 @@ var ts;
116690
116752
  function createDirectory(dirPath) {
116691
116753
  var path = toPath(dirPath);
116692
116754
  var result = getCachedFileSystemEntriesForBaseDir(path);
116693
- var baseFileName = getBaseNameOfFileName(dirPath);
116694
116755
  if (result) {
116695
- updateFileSystemEntry(result.directories, baseFileName, /*isValid*/ true);
116756
+ var baseName = getBaseNameOfFileName(dirPath);
116757
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
116758
+ var canonicalizedDirectories = result.sortedAndCanonicalizedDirectories;
116759
+ // Case-sensitive comparison since already canonicalized
116760
+ if (ts.insertSorted(canonicalizedDirectories, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
116761
+ result.directories.push(baseName);
116762
+ }
116696
116763
  }
116697
116764
  host.createDirectory(dirPath);
116698
116765
  }
@@ -116761,7 +116828,7 @@ var ts;
116761
116828
  fileExists: host.fileExists(fileOrDirectoryPath),
116762
116829
  directoryExists: host.directoryExists(fileOrDirectoryPath)
116763
116830
  };
116764
- if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
116831
+ if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
116765
116832
  // Folder added or removed, clear the cache instead of updating the folder and its structure
116766
116833
  clearCache();
116767
116834
  }
@@ -116781,7 +116848,23 @@ var ts;
116781
116848
  }
116782
116849
  }
116783
116850
  function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
116784
- updateFileSystemEntry(parentResult.files, baseName, fileExists);
116851
+ var canonicalizedFiles = parentResult.sortedAndCanonicalizedFiles;
116852
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
116853
+ if (fileExists) {
116854
+ // Case-sensitive comparison since already canonicalized
116855
+ if (ts.insertSorted(canonicalizedFiles, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
116856
+ parentResult.files.push(baseName);
116857
+ }
116858
+ }
116859
+ else {
116860
+ // Case-sensitive comparison since already canonicalized
116861
+ var sortedIndex = ts.binarySearch(canonicalizedFiles, canonicalizedBaseName, ts.identity, ts.compareStringsCaseSensitive);
116862
+ if (sortedIndex >= 0) {
116863
+ canonicalizedFiles.splice(sortedIndex, 1);
116864
+ var unsortedIndex = parentResult.files.findIndex(function (entry) { return getCanonicalFileName(entry) === canonicalizedBaseName; });
116865
+ parentResult.files.splice(unsortedIndex, 1);
116866
+ }
116867
+ }
116785
116868
  }
116786
116869
  function clearCache() {
116787
116870
  cachedReadDirectoryResult.clear();
@@ -125019,18 +125102,14 @@ var ts;
125019
125102
  if (host.getBuildInfo) {
125020
125103
  // host provides buildinfo, get it from there. This allows host to cache it
125021
125104
  buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
125022
- if (!buildInfo)
125023
- return undefined;
125024
125105
  }
125025
125106
  else {
125026
125107
  var content = host.readFile(buildInfoPath);
125027
125108
  if (!content)
125028
125109
  return undefined;
125029
- buildInfo = ts.getBuildInfo(content);
125110
+ buildInfo = ts.getBuildInfo(buildInfoPath, content);
125030
125111
  }
125031
- if (buildInfo.version !== ts.version)
125032
- return undefined;
125033
- if (!buildInfo.program)
125112
+ if (!buildInfo || buildInfo.version !== ts.version || !buildInfo.program)
125034
125113
  return undefined;
125035
125114
  return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
125036
125115
  }
@@ -125252,7 +125331,8 @@ var ts;
125252
125331
  }
125253
125332
  // All resolutions are invalid if user provided resolutions
125254
125333
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
125255
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
125334
+ var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
125335
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
125256
125336
  if (hasChangedConfigFileParsingErrors) {
125257
125337
  if (reportFileChangeDetectedOnCreateProgram) {
125258
125338
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -125271,6 +125351,11 @@ var ts;
125271
125351
  if (host.afterProgramCreate && program !== builderProgram) {
125272
125352
  host.afterProgramCreate(builderProgram);
125273
125353
  }
125354
+ compilerHost.readFile = originalReadFile;
125355
+ compilerHost.fileExists = originalFileExists;
125356
+ compilerHost.directoryExists = originalDirectoryExists;
125357
+ compilerHost.createDirectory = originalCreateDirectory;
125358
+ compilerHost.writeFile = originalWriteFile;
125274
125359
  return builderProgram;
125275
125360
  }
125276
125361
  function createNewProgram(hasInvalidatedResolution) {
@@ -125748,19 +125833,20 @@ var ts;
125748
125833
  */
125749
125834
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
125750
125835
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
125751
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
125752
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
125753
- UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
125754
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
125755
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
125756
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
125757
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
125758
- UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
125836
+ UpToDateStatusType[UpToDateStatusType["ErrorReadingFile"] = 5] = "ErrorReadingFile";
125837
+ UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 6] = "OutOfDateWithSelf";
125838
+ UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 7] = "OutOfDateWithUpstream";
125839
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 8] = "OutOfDateBuildInfo";
125840
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 9] = "UpstreamOutOfDate";
125841
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 10] = "UpstreamBlocked";
125842
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 11] = "ComputingUpstream";
125843
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 12] = "TsVersionOutputOfDate";
125844
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 13] = "UpToDateWithInputFileText";
125759
125845
  /**
125760
125846
  * Projects with no outputs (i.e. "solution" files)
125761
125847
  */
125762
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
125763
- UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
125848
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 14] = "ContainerOnly";
125849
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 15] = "ForceBuild";
125764
125850
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
125765
125851
  function resolveConfigFileProjectName(project) {
125766
125852
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -126462,13 +126548,13 @@ var ts;
126462
126548
  var emitterDiagnostics = ts.createDiagnosticCollection();
126463
126549
  var emittedOutputs = new ts.Map();
126464
126550
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
126465
- var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
126551
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo || undefined;
126466
126552
  outputFiles.forEach(function (_a) {
126467
126553
  var _b, _c;
126468
126554
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
126469
126555
  emittedOutputs.set(toPath(state, name), name);
126470
126556
  if (buildInfo) {
126471
- if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) {
126557
+ if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo === null || existingBuildInfo === void 0 ? void 0 : existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) {
126472
126558
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
126473
126559
  }
126474
126560
  setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags);
@@ -126761,8 +126847,7 @@ var ts;
126761
126847
  return existing.buildInfo || undefined;
126762
126848
  }
126763
126849
  var value = state.readFileWithCache(buildInfoPath);
126764
- var buildInfo = value ? ts.getBuildInfo(value) : undefined;
126765
- ts.Debug.assert(modifiedTime || !buildInfo);
126850
+ var buildInfo = value ? ts.getBuildInfo(buildInfoPath, value) : undefined;
126766
126851
  state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
126767
126852
  return buildInfo;
126768
126853
  }
@@ -126847,7 +126932,14 @@ var ts;
126847
126932
  missingOutputFileName: buildInfoPath
126848
126933
  };
126849
126934
  }
126850
- var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
126935
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime);
126936
+ if (!buildInfo) {
126937
+ // Error reading buildInfo
126938
+ return {
126939
+ type: ts.UpToDateStatusType.ErrorReadingFile,
126940
+ fileName: buildInfoPath
126941
+ };
126942
+ }
126851
126943
  if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
126852
126944
  return {
126853
126945
  type: ts.UpToDateStatusType.TsVersionOutputOfDate,
@@ -127505,6 +127597,8 @@ var ts;
127505
127597
  return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_1_is_older_than_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerProjectName));
127506
127598
  case ts.UpToDateStatusType.OutputMissing:
127507
127599
  return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(state, configFileName), relName(state, status.missingOutputFileName));
127600
+ case ts.UpToDateStatusType.ErrorReadingFile:
127601
+ return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_there_was_error_reading_file_1, relName(state, configFileName), relName(state, status.fileName));
127508
127602
  case ts.UpToDateStatusType.OutOfDateBuildInfo:
127509
127603
  return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted, relName(state, configFileName), relName(state, status.buildInfoFile));
127510
127604
  case ts.UpToDateStatusType.UpToDate:
@@ -156539,6 +156633,15 @@ var ts;
156539
156633
  ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code,
156540
156634
  ts.Diagnostics.Cannot_find_name_0.code
156541
156635
  ];
156636
+ var InfoKind;
156637
+ (function (InfoKind) {
156638
+ InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
156639
+ InfoKind[InfoKind["Enum"] = 1] = "Enum";
156640
+ InfoKind[InfoKind["Function"] = 2] = "Function";
156641
+ InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
156642
+ InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
156643
+ InfoKind[InfoKind["Signature"] = 5] = "Signature";
156644
+ })(InfoKind || (InfoKind = {}));
156542
156645
  codefix.registerCodeFix({
156543
156646
  errorCodes: errorCodes,
156544
156647
  getCodeActions: function (context) {
@@ -156547,19 +156650,19 @@ var ts;
156547
156650
  if (!info) {
156548
156651
  return undefined;
156549
156652
  }
156550
- if (info.kind === 3 /* ObjectLiteral */) {
156653
+ if (info.kind === InfoKind.ObjectLiteral) {
156551
156654
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); });
156552
156655
  return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)];
156553
156656
  }
156554
- if (info.kind === 4 /* JsxAttributes */) {
156657
+ if (info.kind === InfoKind.JsxAttributes) {
156555
156658
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); });
156556
156659
  return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)];
156557
156660
  }
156558
- if (info.kind === 2 /* Function */) {
156661
+ if (info.kind === InfoKind.Function || info.kind === InfoKind.Signature) {
156559
156662
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); });
156560
156663
  return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)];
156561
156664
  }
156562
- if (info.kind === 1 /* Enum */) {
156665
+ if (info.kind === InfoKind.Enum) {
156563
156666
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); });
156564
156667
  return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
156565
156668
  }
@@ -156577,20 +156680,20 @@ var ts;
156577
156680
  if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) {
156578
156681
  return;
156579
156682
  }
156580
- if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) {
156683
+ if (fixId === fixMissingFunctionDeclaration && (info.kind === InfoKind.Function || info.kind === InfoKind.Signature)) {
156581
156684
  addFunctionDeclaration(changes, context, info);
156582
156685
  }
156583
- else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
156686
+ else if (fixId === fixMissingProperties && info.kind === InfoKind.ObjectLiteral) {
156584
156687
  addObjectLiteralProperties(changes, context, info);
156585
156688
  }
156586
- else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
156689
+ else if (fixId === fixMissingAttributes && info.kind === InfoKind.JsxAttributes) {
156587
156690
  addJsxAttributes(changes, context, info);
156588
156691
  }
156589
156692
  else {
156590
- if (info.kind === 1 /* Enum */) {
156693
+ if (info.kind === InfoKind.Enum) {
156591
156694
  addEnumMemberDeclaration(changes, checker, info);
156592
156695
  }
156593
- if (info.kind === 0 /* TypeLikeDeclaration */) {
156696
+ if (info.kind === InfoKind.TypeLikeDeclaration) {
156594
156697
  var parentDeclaration = info.parentDeclaration, token_1 = info.token;
156595
156698
  var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; });
156596
156699
  if (!infos.some(function (i) { return i.token.text === token_1.text; })) {
@@ -156634,14 +156737,6 @@ var ts;
156634
156737
  }));
156635
156738
  },
156636
156739
  });
156637
- var InfoKind;
156638
- (function (InfoKind) {
156639
- InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
156640
- InfoKind[InfoKind["Enum"] = 1] = "Enum";
156641
- InfoKind[InfoKind["Function"] = 2] = "Function";
156642
- InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
156643
- InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
156644
- })(InfoKind || (InfoKind = {}));
156645
156740
  function getInfo(sourceFile, tokenPos, errorCode, checker, program) {
156646
156741
  // The identifier of the missing property. eg:
156647
156742
  // this.missing = 1;
@@ -156663,7 +156758,7 @@ var ts;
156663
156758
  var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
156664
156759
  if (!ts.length(properties))
156665
156760
  return undefined;
156666
- return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent };
156761
+ return { kind: InfoKind.ObjectLiteral, token: param.name, properties: properties, parentDeclaration: parent };
156667
156762
  }
156668
156763
  if (!ts.isMemberName(token))
156669
156764
  return undefined;
@@ -156671,17 +156766,26 @@ var ts;
156671
156766
  var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
156672
156767
  if (!ts.length(properties))
156673
156768
  return undefined;
156674
- return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer };
156769
+ return { kind: InfoKind.ObjectLiteral, token: token, properties: properties, parentDeclaration: parent.initializer };
156675
156770
  }
156676
156771
  if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) {
156677
156772
  var target = ts.getEmitScriptTarget(program.getCompilerOptions());
156678
156773
  var attributes = getUnmatchedAttributes(checker, target, token.parent);
156679
156774
  if (!ts.length(attributes))
156680
156775
  return undefined;
156681
- return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
156776
+ return { kind: InfoKind.JsxAttributes, token: token, attributes: attributes, parentDeclaration: token.parent };
156682
156777
  }
156683
- if (ts.isIdentifier(token) && ts.isCallExpression(parent) && parent.expression === token) {
156684
- return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile };
156778
+ if (ts.isIdentifier(token)) {
156779
+ var type = checker.getContextualType(token);
156780
+ if (type && ts.getObjectFlags(type) & 16 /* Anonymous */) {
156781
+ var signature = ts.firstOrUndefined(checker.getSignaturesOfType(type, 0 /* Call */));
156782
+ if (signature === undefined)
156783
+ return undefined;
156784
+ return { kind: InfoKind.Signature, token: token, signature: signature, sourceFile: sourceFile, parentDeclaration: findScope(token) };
156785
+ }
156786
+ if (ts.isCallExpression(parent) && parent.expression === token) {
156787
+ return { kind: InfoKind.Function, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: findScope(token) };
156788
+ }
156685
156789
  }
156686
156790
  if (!ts.isPropertyAccessExpression(parent))
156687
156791
  return undefined;
@@ -156693,13 +156797,13 @@ var ts;
156693
156797
  var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
156694
156798
  var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
156695
156799
  if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
156696
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration };
156800
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration };
156697
156801
  }
156698
156802
  var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
156699
156803
  if (sourceFile.commonJsModuleIndicator)
156700
156804
  return undefined;
156701
156805
  if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
156702
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile };
156806
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile };
156703
156807
  }
156704
156808
  }
156705
156809
  var classDeclaration = ts.find(symbol.declarations, ts.isClassLike);
@@ -156717,11 +156821,11 @@ var ts;
156717
156821
  (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */);
156718
156822
  var isJSFile = ts.isSourceFileJS(declSourceFile);
156719
156823
  var call = ts.tryCast(parent.parent, ts.isCallExpression);
156720
- return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
156824
+ return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
156721
156825
  }
156722
156826
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
156723
156827
  if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
156724
- return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration };
156828
+ return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
156725
156829
  }
156726
156830
  return undefined;
156727
156831
  }
@@ -156897,9 +157001,17 @@ var ts;
156897
157001
  });
156898
157002
  }
156899
157003
  function addFunctionDeclaration(changes, context, info) {
157004
+ var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
156900
157005
  var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
156901
- var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration);
156902
- changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
157006
+ var functionDeclaration = info.kind === InfoKind.Function
157007
+ ? codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration)
157008
+ : codefix.createSignatureDeclarationFromSignature(256 /* FunctionDeclaration */, context, quotePreference, info.signature, codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), info.token, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder);
157009
+ if (functionDeclaration === undefined) {
157010
+ ts.Debug.fail("fixMissingFunctionDeclaration codefix got unexpected error.");
157011
+ }
157012
+ ts.isReturnStatement(info.parentDeclaration)
157013
+ ? changes.insertNodeBefore(info.sourceFile, info.parentDeclaration, functionDeclaration, /*blankLineBetween*/ true)
157014
+ : changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
156903
157015
  importAdder.writeFixes(changes);
156904
157016
  }
156905
157017
  function addJsxAttributes(changes, context, info) {
@@ -157057,6 +157169,14 @@ var ts;
157057
157169
  }
157058
157170
  return ts.createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === 0 /* Single */);
157059
157171
  }
157172
+ function findScope(node) {
157173
+ if (ts.findAncestor(node, ts.isJsxExpression)) {
157174
+ var returnStatement = ts.findAncestor(node.parent, ts.isReturnStatement);
157175
+ if (returnStatement)
157176
+ return returnStatement;
157177
+ }
157178
+ return ts.getSourceFileOfNode(node);
157179
+ }
157060
157180
  })(codefix = ts.codefix || (ts.codefix = {}));
157061
157181
  })(ts || (ts = {}));
157062
157182
  /* @internal */
@@ -159746,6 +159866,9 @@ var ts;
159746
159866
  if (ts.isMethodDeclaration(signatureDeclaration)) {
159747
159867
  return ts.factory.updateMethodDeclaration(signatureDeclaration, modifiers, asteriskToken, name !== null && name !== void 0 ? name : ts.factory.createIdentifier(""), questionToken, typeParameters, parameters, type, body);
159748
159868
  }
159869
+ if (ts.isFunctionDeclaration(signatureDeclaration)) {
159870
+ return ts.factory.updateFunctionDeclaration(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body);
159871
+ }
159749
159872
  return undefined;
159750
159873
  }
159751
159874
  codefix.createSignatureDeclarationFromSignature = createSignatureDeclarationFromSignature;
@@ -167048,6 +167171,10 @@ var ts;
167048
167171
  getCurrentDirectory: compilerHost.getCurrentDirectory,
167049
167172
  onUnRecoverableConfigFileDiagnostic: ts.noop,
167050
167173
  };
167174
+ // The call to isProgramUptoDate below may refer back to documentRegistryBucketKey;
167175
+ // calculate this early so it's not undefined if downleveled to a var (or, if emitted
167176
+ // as a const variable without downleveling, doesn't crash).
167177
+ var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
167051
167178
  // If the program is already up-to-date, we can reuse it
167052
167179
  if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
167053
167180
  return;
@@ -167057,7 +167184,6 @@ var ts;
167057
167184
  // instance. If we cancel midway through, we may end up in an inconsistent state where
167058
167185
  // the program points to old source files that have been invalidated because of
167059
167186
  // incremental parsing.
167060
- var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
167061
167187
  var options = {
167062
167188
  rootNames: rootFileNames,
167063
167189
  options: newSettings,