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.
@@ -85,11 +85,11 @@ var ts;
85
85
  (function (ts) {
86
86
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
87
87
  // If changing the text in this section, be sure to test `configurePrerelease` too.
88
- ts.versionMajorMinor = "4.8";
88
+ ts.versionMajorMinor = "4.9";
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220807";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220811";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -111,7 +111,11 @@ var ts;
111
111
  // Internet Explorer's Map doesn't support iteration, so don't use it.
112
112
  var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
113
113
  // eslint-disable-next-line no-in-operator
114
- return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
114
+ var constructor = typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
115
+ if (!constructor) {
116
+ throw new Error("No compatible Map implementation found.");
117
+ }
118
+ return constructor;
115
119
  }
116
120
  NativeCollections.tryGetNativeMap = tryGetNativeMap;
117
121
  /**
@@ -121,23 +125,18 @@ var ts;
121
125
  // Internet Explorer's Set doesn't support iteration, so don't use it.
122
126
  var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
123
127
  // eslint-disable-next-line no-in-operator
124
- return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
128
+ var constructor = typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
129
+ if (!constructor) {
130
+ throw new Error("No compatible Set implementation found.");
131
+ }
132
+ return constructor;
125
133
  }
126
134
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
127
135
  })(NativeCollections || (NativeCollections = {}));
128
136
  /* @internal */
129
- ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
130
- /* @internal */
131
- ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
137
+ ts.Map = NativeCollections.tryGetNativeMap();
132
138
  /* @internal */
133
- function getCollectionImplementation(name, nativeFactory, shimFactory) {
134
- var _a;
135
- // NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it.
136
- var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator);
137
- if (constructor)
138
- return constructor;
139
- throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");
140
- }
139
+ ts.Set = NativeCollections.tryGetNativeSet();
141
140
  })(ts || (ts = {}));
142
141
  /* @internal */
143
142
  var ts;
@@ -853,15 +852,18 @@ var ts;
853
852
  function insertSorted(array, insert, compare, allowDuplicates) {
854
853
  if (array.length === 0) {
855
854
  array.push(insert);
856
- return;
855
+ return true;
857
856
  }
858
857
  var insertIndex = binarySearch(array, insert, identity, compare);
859
858
  if (insertIndex < 0) {
860
859
  array.splice(~insertIndex, 0, insert);
860
+ return true;
861
861
  }
862
- else if (allowDuplicates) {
862
+ if (allowDuplicates) {
863
863
  array.splice(insertIndex, 0, insert);
864
+ return true;
864
865
  }
866
+ return false;
865
867
  }
866
868
  ts.insertSorted = insertSorted;
867
869
  function sortAndDeduplicate(array, comparer, equalityComparer) {
@@ -7822,12 +7824,9 @@ var ts;
7822
7824
  * Normalize path separators, converting `\` into `/`.
7823
7825
  */
7824
7826
  function normalizeSlashes(path) {
7825
- var index = path.indexOf("\\");
7826
- if (index === -1) {
7827
- return path;
7828
- }
7829
- backslashRegExp.lastIndex = index; // prime regex with known position
7830
- return path.replace(backslashRegExp, ts.directorySeparator);
7827
+ return path.indexOf("\\") !== -1
7828
+ ? path.replace(backslashRegExp, ts.directorySeparator)
7829
+ : path;
7831
7830
  }
7832
7831
  ts.normalizeSlashes = normalizeSlashes;
7833
7832
  /**
@@ -9528,6 +9527,7 @@ var ts;
9528
9527
  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."),
9529
9528
  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"),
9530
9529
  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"),
9530
+ 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}'"),
9531
9531
  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}'"),
9532
9532
  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."),
9533
9533
  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."),
@@ -19371,21 +19371,17 @@ var ts;
19371
19371
  return getStringFromExpandedCharCodes(expandedCharCodes);
19372
19372
  }
19373
19373
  ts.base64decode = base64decode;
19374
+ function readJsonOrUndefined(path, hostOrText) {
19375
+ var jsonText = ts.isString(hostOrText) ? hostOrText : hostOrText.readFile(path);
19376
+ if (!jsonText)
19377
+ return undefined;
19378
+ // gracefully handle if readFile fails or returns not JSON
19379
+ var result = ts.parseConfigFileTextToJson(path, jsonText);
19380
+ return !result.error ? result.config : undefined;
19381
+ }
19382
+ ts.readJsonOrUndefined = readJsonOrUndefined;
19374
19383
  function readJson(path, host) {
19375
- try {
19376
- var jsonText = host.readFile(path);
19377
- if (!jsonText)
19378
- return {};
19379
- var result = ts.parseConfigFileTextToJson(path, jsonText);
19380
- if (result.error) {
19381
- return {};
19382
- }
19383
- return result.config;
19384
- }
19385
- catch (e) {
19386
- // gracefully handle if readFile fails or returns not JSON
19387
- return {};
19388
- }
19384
+ return readJsonOrUndefined(path, host) || {};
19389
19385
  }
19390
19386
  ts.readJson = readJson;
19391
19387
  function directoryProbablyExists(directoryName, host) {
@@ -27736,9 +27732,10 @@ var ts;
27736
27732
  };
27737
27733
  var buildInfo_1;
27738
27734
  var getAndCacheBuildInfo_1 = function (getText) {
27735
+ var _a;
27739
27736
  if (buildInfo_1 === undefined) {
27740
27737
  var result = getText();
27741
- buildInfo_1 = result !== undefined ? ts.getBuildInfo(result) : false;
27738
+ buildInfo_1 = result !== undefined ? (_a = ts.getBuildInfo(node.buildInfoPath, result)) !== null && _a !== void 0 ? _a : false : false;
27742
27739
  }
27743
27740
  return buildInfo_1 || undefined;
27744
27741
  };
@@ -45798,6 +45795,9 @@ var ts;
45798
45795
  case 203 /* BindingElement */:
45799
45796
  bindBindingElementFlow(node);
45800
45797
  break;
45798
+ case 164 /* Parameter */:
45799
+ bindParameterFlow(node);
45800
+ break;
45801
45801
  case 205 /* ObjectLiteralExpression */:
45802
45802
  case 204 /* ArrayLiteralExpression */:
45803
45803
  case 296 /* PropertyAssignment */:
@@ -46538,20 +46538,38 @@ var ts;
46538
46538
  }
46539
46539
  }
46540
46540
  function bindBindingElementFlow(node) {
46541
- if (ts.isBindingPattern(node.name)) {
46542
- // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46543
- // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46544
- // - `BindingElement: BindingPattern Initializer?`
46545
- // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46546
- // - `BindingElement: BindingPattern Initializer?`
46547
- bind(node.dotDotDotToken);
46548
- bind(node.propertyName);
46549
- bind(node.initializer);
46550
- bind(node.name);
46541
+ // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46542
+ // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46543
+ // - `BindingElement: BindingPattern Initializer?`
46544
+ // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46545
+ // - `BindingElement: BindingPattern Initializer?`
46546
+ bind(node.dotDotDotToken);
46547
+ bind(node.propertyName);
46548
+ bindInitializer(node.initializer);
46549
+ bind(node.name);
46550
+ }
46551
+ function bindParameterFlow(node) {
46552
+ bindEach(node.modifiers);
46553
+ bind(node.dotDotDotToken);
46554
+ bind(node.questionToken);
46555
+ bind(node.type);
46556
+ bindInitializer(node.initializer);
46557
+ bind(node.name);
46558
+ }
46559
+ // a BindingElement/Parameter does not have side effects if initializers are not evaluated and used. (see GH#49759)
46560
+ function bindInitializer(node) {
46561
+ if (!node) {
46562
+ return;
46551
46563
  }
46552
- else {
46553
- bindEachChild(node);
46564
+ var entryFlow = currentFlow;
46565
+ bind(node);
46566
+ if (entryFlow === unreachableFlow || entryFlow === currentFlow) {
46567
+ return;
46554
46568
  }
46569
+ var exitFlow = createBranchLabel();
46570
+ addAntecedent(exitFlow, entryFlow);
46571
+ addAntecedent(exitFlow, currentFlow);
46572
+ currentFlow = finishFlowLabel(exitFlow);
46555
46573
  }
46556
46574
  function bindJSDocTypeAlias(node) {
46557
46575
  bind(node.tagName);
@@ -49722,7 +49740,7 @@ var ts;
49722
49740
  if (unidirectional === void 0) { unidirectional = false; }
49723
49741
  source.forEach(function (sourceSymbol, id) {
49724
49742
  var targetSymbol = target.get(id);
49725
- target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
49743
+ target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : getMergedSymbol(sourceSymbol));
49726
49744
  });
49727
49745
  }
49728
49746
  function mergeModuleAugmentation(moduleName) {
@@ -56513,11 +56531,9 @@ var ts;
56513
56531
  return getReturnTypeOfSignature(getterSignature);
56514
56532
  }
56515
56533
  }
56516
- if (ts.isInJSFile(declaration)) {
56517
- var type_1 = getParameterTypeOfTypeTag(func, declaration);
56518
- if (type_1)
56519
- return type_1;
56520
- }
56534
+ var parameterTypeOfTypeTag = getParameterTypeOfTypeTag(func, declaration);
56535
+ if (parameterTypeOfTypeTag)
56536
+ return parameterTypeOfTypeTag;
56521
56537
  // Use contextual parameter type if one is available
56522
56538
  var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
56523
56539
  if (type) {
@@ -57093,9 +57109,9 @@ var ts;
57093
57109
  if (typeNode === undefined) {
57094
57110
  return useUnknownInCatchVariables ? unknownType : anyType;
57095
57111
  }
57096
- var type_2 = getTypeOfNode(typeNode);
57112
+ var type_1 = getTypeOfNode(typeNode);
57097
57113
  // an errorType will make `checkTryStatement` issue an error
57098
- return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
57114
+ return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
57099
57115
  }
57100
57116
  // Handle export default expressions
57101
57117
  if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
@@ -57305,11 +57321,11 @@ var ts;
57305
57321
  return errorType;
57306
57322
  }
57307
57323
  var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
57308
- var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57324
+ var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57309
57325
  if (!popTypeResolution()) {
57310
57326
  return reportCircularityError(symbol);
57311
57327
  }
57312
- return type_3;
57328
+ return type_2;
57313
57329
  }
57314
57330
  }
57315
57331
  var type = createObjectType(16 /* Anonymous */, symbol);
@@ -59532,10 +59548,10 @@ var ts;
59532
59548
  var baseTypes = [];
59533
59549
  var different = false;
59534
59550
  for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
59535
- var type_4 = types_7[_i];
59536
- var baseType = getBaseConstraint(type_4);
59551
+ var type_3 = types_7[_i];
59552
+ var baseType = getBaseConstraint(type_3);
59537
59553
  if (baseType) {
59538
- if (baseType !== type_4) {
59554
+ if (baseType !== type_3) {
59539
59555
  different = true;
59540
59556
  }
59541
59557
  baseTypes.push(baseType);
@@ -60326,7 +60342,12 @@ var ts;
60326
60342
  continue;
60327
60343
  }
60328
60344
  }
60329
- result.push(getSignatureFromDeclaration(decl));
60345
+ // If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters.
60346
+ // 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.
60347
+ result.push((!ts.isFunctionExpressionOrArrowFunction(decl) &&
60348
+ !ts.isObjectLiteralMethod(decl) &&
60349
+ getSignatureOfTypeTag(decl)) ||
60350
+ getSignatureFromDeclaration(decl));
60330
60351
  }
60331
60352
  return result;
60332
60353
  }
@@ -60357,7 +60378,7 @@ var ts;
60357
60378
  else {
60358
60379
  var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
60359
60380
  var jsdocPredicate = void 0;
60360
- if (!type && ts.isInJSFile(signature.declaration)) {
60381
+ if (!type) {
60361
60382
  var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
60362
60383
  if (jsdocSignature && signature !== jsdocSignature) {
60363
60384
  jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
@@ -64383,15 +64404,14 @@ var ts;
64383
64404
  return false;
64384
64405
  }
64385
64406
  function isContextSensitiveFunctionLikeDeclaration(node) {
64386
- return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
64387
- (ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
64407
+ return ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node);
64388
64408
  }
64389
64409
  function hasContextSensitiveReturnExpression(node) {
64390
64410
  // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value.
64391
64411
  return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body);
64392
64412
  }
64393
64413
  function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
64394
- return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64414
+ return (ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64395
64415
  isContextSensitiveFunctionLikeDeclaration(func);
64396
64416
  }
64397
64417
  function getTypeWithoutSignatures(type) {
@@ -73449,9 +73469,11 @@ var ts;
73449
73469
  case 1 /* ExportsProperty */:
73450
73470
  case 6 /* Prototype */:
73451
73471
  case 3 /* PrototypeProperty */:
73452
- var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
73453
- // falls through
73454
73472
  case 2 /* ModuleExports */:
73473
+ var valueDeclaration = void 0;
73474
+ if (kind !== 2 /* ModuleExports */) {
73475
+ valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
73476
+ }
73455
73477
  valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration);
73456
73478
  var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration);
73457
73479
  return annotated ? getTypeFromTypeNode(annotated) : undefined;
@@ -73929,9 +73951,18 @@ var ts;
73929
73951
  if (!isErrorType(intrinsicClassAttribs)) {
73930
73952
  var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
73931
73953
  var hostClassType = getReturnTypeOfSignature(sig);
73932
- apparentAttributesType = intersectTypes(typeParams
73933
- ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
73934
- : intrinsicClassAttribs, apparentAttributesType);
73954
+ var libraryManagedAttributeType = void 0;
73955
+ if (typeParams && typeParams.length === 1) {
73956
+ var inferredArgs = fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context));
73957
+ libraryManagedAttributeType = instantiateType(intrinsicClassAttribs, createTypeMapper(typeParams, inferredArgs));
73958
+ }
73959
+ else if (typeParams)
73960
+ libraryManagedAttributeType = undefined;
73961
+ else
73962
+ libraryManagedAttributeType = intrinsicClassAttribs;
73963
+ if (libraryManagedAttributeType) {
73964
+ apparentAttributesType = intersectTypes(libraryManagedAttributeType, apparentAttributesType);
73965
+ }
73935
73966
  }
73936
73967
  var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
73937
73968
  if (!isErrorType(intrinsicAttribs)) {
@@ -74436,16 +74467,30 @@ var ts;
74436
74467
  // If object literal is contextually typed by the implied type of a binding pattern, augment the result
74437
74468
  // type with those properties for which the binding pattern specifies a default value.
74438
74469
  // If the object literal is spread into another object literal, skip this step and let the top-level object
74439
- // literal handle it instead.
74440
- if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) {
74441
- for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74442
- var prop = _e[_d];
74443
- if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74444
- if (!(prop.flags & 16777216 /* Optional */)) {
74445
- error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74470
+ // literal handle it instead. Note that this might require full traversal to the root pattern's parent
74471
+ // as it's the guaranteed to be the common ancestor of the pattern node and the current object node.
74472
+ // It's not possible to check if the immediate parent node is a spread assignment
74473
+ // since the type flows in non-obvious ways through conditional expressions, IIFEs and more.
74474
+ if (contextualTypeHasPattern) {
74475
+ var rootPatternParent_1 = ts.findAncestor(contextualType.pattern.parent, function (n) {
74476
+ return n.kind === 254 /* VariableDeclaration */ ||
74477
+ n.kind === 221 /* BinaryExpression */ ||
74478
+ n.kind === 164 /* Parameter */;
74479
+ });
74480
+ var spreadOrOutsideRootObject = ts.findAncestor(node, function (n) {
74481
+ return n === rootPatternParent_1 ||
74482
+ n.kind === 298 /* SpreadAssignment */;
74483
+ });
74484
+ if (spreadOrOutsideRootObject.kind !== 298 /* SpreadAssignment */) {
74485
+ for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74486
+ var prop = _e[_d];
74487
+ if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74488
+ if (!(prop.flags & 16777216 /* Optional */)) {
74489
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74490
+ }
74491
+ propertiesTable.set(prop.escapedName, prop);
74492
+ propertiesArray.push(prop);
74446
74493
  }
74447
- propertiesTable.set(prop.escapedName, prop);
74448
- propertiesArray.push(prop);
74449
74494
  }
74450
74495
  }
74451
74496
  }
@@ -77744,12 +77789,15 @@ var ts;
77744
77789
  return false;
77745
77790
  }
77746
77791
  var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
77747
- ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
77792
+ (ts.isVariableDeclaration(node) || ts.isPropertyAssignment(node)) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
77748
77793
  undefined;
77749
77794
  if (func) {
77750
- // If the node has a @class tag, treat it like a constructor.
77795
+ // If the node has a @class or @constructor tag, treat it like a constructor.
77751
77796
  if (ts.getJSDocClassTag(node))
77752
77797
  return true;
77798
+ // If the node is a property of an object literal.
77799
+ if (ts.isPropertyAssignment(ts.walkUpParenthesizedExpressions(func.parent)))
77800
+ return false;
77753
77801
  // If the symbol of the node has members, treat it like a constructor.
77754
77802
  var symbol = getSymbolOfNode(func);
77755
77803
  return !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.members) === null || _a === void 0 ? void 0 : _a.size);
@@ -77997,8 +78045,8 @@ var ts;
77997
78045
  if (hasDefaultOnly && type && !isErrorType(type)) {
77998
78046
  var synthType = type;
77999
78047
  if (!synthType.defaultOnlyType) {
78000
- var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78001
- synthType.defaultOnlyType = type_5;
78048
+ var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78049
+ synthType.defaultOnlyType = type_4;
78002
78050
  }
78003
78051
  return synthType.defaultOnlyType;
78004
78052
  }
@@ -87335,6 +87383,12 @@ var ts;
87335
87383
  return resolveJSDocMemberName(name, /*ignoreErrors*/ false, getSymbolOfNode(container));
87336
87384
  }
87337
87385
  }
87386
+ if (result && isJSDoc_1) {
87387
+ var container = ts.getJSDocHost(name);
87388
+ if (container && ts.isEnumMember(container) && container === result.valueDeclaration) {
87389
+ return resolveEntityName(name, meaning, /*ignoreErrors*/ true, /* dontResolveAlias */ true, ts.getSourceFileOfNode(container)) || result;
87390
+ }
87391
+ }
87338
87392
  return result;
87339
87393
  }
87340
87394
  else if (ts.isPrivateIdentifier(name)) {
@@ -107496,6 +107550,13 @@ var ts;
107496
107550
  ts.Debug.assert(importVariableName !== undefined);
107497
107551
  // save import into the local
107498
107552
  statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
107553
+ if (ts.hasSyntacticModifier(entry, 1 /* Export */)) {
107554
+ statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction,
107555
+ /*typeArguments*/ undefined, [
107556
+ factory.createStringLiteral(ts.idText(importVariableName)),
107557
+ parameterName,
107558
+ ])));
107559
+ }
107499
107560
  break;
107500
107561
  case 272 /* ExportDeclaration */:
107501
107562
  ts.Debug.assert(importVariableName !== undefined);
@@ -110338,8 +110399,12 @@ var ts;
110338
110399
  }
110339
110400
  var previousNeedsDeclare = needsDeclare;
110340
110401
  switch (input.kind) {
110341
- case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all
110342
- return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110402
+ case 259 /* TypeAliasDeclaration */: {
110403
+ needsDeclare = false;
110404
+ var clean = cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110405
+ needsDeclare = previousNeedsDeclare;
110406
+ return clean;
110407
+ }
110343
110408
  case 258 /* InterfaceDeclaration */: {
110344
110409
  return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
110345
110410
  }
@@ -111843,8 +111908,8 @@ var ts;
111843
111908
  }
111844
111909
  ts.getBuildInfoText = getBuildInfoText;
111845
111910
  /*@internal*/
111846
- function getBuildInfo(buildInfoText) {
111847
- return JSON.parse(buildInfoText);
111911
+ function getBuildInfo(buildInfoFile, buildInfoText) {
111912
+ return ts.readJsonOrUndefined(buildInfoFile, buildInfoText);
111848
111913
  }
111849
111914
  ts.getBuildInfo = getBuildInfo;
111850
111915
  /*@internal*/
@@ -111922,17 +111987,16 @@ var ts;
111922
111987
  var buildInfo;
111923
111988
  if (host.getBuildInfo) {
111924
111989
  // If host directly provides buildinfo we can get it directly. This allows host to cache the buildinfo
111925
- var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
111926
- if (!hostBuildInfo)
111927
- return buildInfoPath;
111928
- buildInfo = hostBuildInfo;
111990
+ buildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
111929
111991
  }
111930
111992
  else {
111931
111993
  var buildInfoText = host.readFile(buildInfoPath);
111932
111994
  if (!buildInfoText)
111933
111995
  return buildInfoPath;
111934
- buildInfo = getBuildInfo(buildInfoText);
111996
+ buildInfo = getBuildInfo(buildInfoPath, buildInfoText);
111935
111997
  }
111998
+ if (!buildInfo)
111999
+ return buildInfoPath;
111936
112000
  if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
111937
112001
  return buildInfoPath;
111938
112002
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
@@ -116590,7 +116654,16 @@ var ts;
116590
116654
  return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
116591
116655
  }
116592
116656
  function getCachedFileSystemEntriesForBaseDir(path) {
116593
- return getCachedFileSystemEntries(ts.getDirectoryPath(path));
116657
+ var entries = getCachedFileSystemEntries(ts.getDirectoryPath(path));
116658
+ if (!entries) {
116659
+ return entries;
116660
+ }
116661
+ // If we're looking for the base directory, we're definitely going to search the entries
116662
+ if (!entries.sortedAndCanonicalizedFiles) {
116663
+ entries.sortedAndCanonicalizedFiles = entries.files.map(getCanonicalFileName).sort();
116664
+ entries.sortedAndCanonicalizedDirectories = entries.directories.map(getCanonicalFileName).sort();
116665
+ }
116666
+ return entries;
116594
116667
  }
116595
116668
  function getBaseNameOfFileName(fileName) {
116596
116669
  return ts.getBaseFileName(ts.normalizePath(fileName));
@@ -116633,21 +116706,10 @@ var ts;
116633
116706
  return undefined;
116634
116707
  }
116635
116708
  }
116636
- function fileNameEqual(name1, name2) {
116637
- return getCanonicalFileName(name1) === getCanonicalFileName(name2);
116638
- }
116639
116709
  function hasEntry(entries, name) {
116640
- return ts.some(entries, function (file) { return fileNameEqual(file, name); });
116641
- }
116642
- function updateFileSystemEntry(entries, baseName, isValid) {
116643
- if (hasEntry(entries, baseName)) {
116644
- if (!isValid) {
116645
- return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
116646
- }
116647
- }
116648
- else if (isValid) {
116649
- return entries.push(baseName);
116650
- }
116710
+ // Case-sensitive comparison since already canonicalized
116711
+ var index = ts.binarySearch(entries, name, ts.identity, ts.compareStringsCaseSensitive);
116712
+ return index >= 0;
116651
116713
  }
116652
116714
  function writeFile(fileName, data, writeByteOrderMark) {
116653
116715
  var path = toPath(fileName);
@@ -116660,7 +116722,7 @@ var ts;
116660
116722
  function fileExists(fileName) {
116661
116723
  var path = toPath(fileName);
116662
116724
  var result = getCachedFileSystemEntriesForBaseDir(path);
116663
- return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
116725
+ return result && hasEntry(result.sortedAndCanonicalizedFiles, getCanonicalFileName(getBaseNameOfFileName(fileName))) ||
116664
116726
  host.fileExists(fileName);
116665
116727
  }
116666
116728
  function directoryExists(dirPath) {
@@ -116670,9 +116732,14 @@ var ts;
116670
116732
  function createDirectory(dirPath) {
116671
116733
  var path = toPath(dirPath);
116672
116734
  var result = getCachedFileSystemEntriesForBaseDir(path);
116673
- var baseFileName = getBaseNameOfFileName(dirPath);
116674
116735
  if (result) {
116675
- updateFileSystemEntry(result.directories, baseFileName, /*isValid*/ true);
116736
+ var baseName = getBaseNameOfFileName(dirPath);
116737
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
116738
+ var canonicalizedDirectories = result.sortedAndCanonicalizedDirectories;
116739
+ // Case-sensitive comparison since already canonicalized
116740
+ if (ts.insertSorted(canonicalizedDirectories, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
116741
+ result.directories.push(baseName);
116742
+ }
116676
116743
  }
116677
116744
  host.createDirectory(dirPath);
116678
116745
  }
@@ -116741,7 +116808,7 @@ var ts;
116741
116808
  fileExists: host.fileExists(fileOrDirectoryPath),
116742
116809
  directoryExists: host.directoryExists(fileOrDirectoryPath)
116743
116810
  };
116744
- if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
116811
+ if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
116745
116812
  // Folder added or removed, clear the cache instead of updating the folder and its structure
116746
116813
  clearCache();
116747
116814
  }
@@ -116761,7 +116828,23 @@ var ts;
116761
116828
  }
116762
116829
  }
116763
116830
  function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
116764
- updateFileSystemEntry(parentResult.files, baseName, fileExists);
116831
+ var canonicalizedFiles = parentResult.sortedAndCanonicalizedFiles;
116832
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
116833
+ if (fileExists) {
116834
+ // Case-sensitive comparison since already canonicalized
116835
+ if (ts.insertSorted(canonicalizedFiles, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
116836
+ parentResult.files.push(baseName);
116837
+ }
116838
+ }
116839
+ else {
116840
+ // Case-sensitive comparison since already canonicalized
116841
+ var sortedIndex = ts.binarySearch(canonicalizedFiles, canonicalizedBaseName, ts.identity, ts.compareStringsCaseSensitive);
116842
+ if (sortedIndex >= 0) {
116843
+ canonicalizedFiles.splice(sortedIndex, 1);
116844
+ var unsortedIndex = parentResult.files.findIndex(function (entry) { return getCanonicalFileName(entry) === canonicalizedBaseName; });
116845
+ parentResult.files.splice(unsortedIndex, 1);
116846
+ }
116847
+ }
116765
116848
  }
116766
116849
  function clearCache() {
116767
116850
  cachedReadDirectoryResult.clear();
@@ -124999,18 +125082,14 @@ var ts;
124999
125082
  if (host.getBuildInfo) {
125000
125083
  // host provides buildinfo, get it from there. This allows host to cache it
125001
125084
  buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
125002
- if (!buildInfo)
125003
- return undefined;
125004
125085
  }
125005
125086
  else {
125006
125087
  var content = host.readFile(buildInfoPath);
125007
125088
  if (!content)
125008
125089
  return undefined;
125009
- buildInfo = ts.getBuildInfo(content);
125090
+ buildInfo = ts.getBuildInfo(buildInfoPath, content);
125010
125091
  }
125011
- if (buildInfo.version !== ts.version)
125012
- return undefined;
125013
- if (!buildInfo.program)
125092
+ if (!buildInfo || buildInfo.version !== ts.version || !buildInfo.program)
125014
125093
  return undefined;
125015
125094
  return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
125016
125095
  }
@@ -125232,7 +125311,8 @@ var ts;
125232
125311
  }
125233
125312
  // All resolutions are invalid if user provided resolutions
125234
125313
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
125235
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
125314
+ var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
125315
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
125236
125316
  if (hasChangedConfigFileParsingErrors) {
125237
125317
  if (reportFileChangeDetectedOnCreateProgram) {
125238
125318
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -125251,6 +125331,11 @@ var ts;
125251
125331
  if (host.afterProgramCreate && program !== builderProgram) {
125252
125332
  host.afterProgramCreate(builderProgram);
125253
125333
  }
125334
+ compilerHost.readFile = originalReadFile;
125335
+ compilerHost.fileExists = originalFileExists;
125336
+ compilerHost.directoryExists = originalDirectoryExists;
125337
+ compilerHost.createDirectory = originalCreateDirectory;
125338
+ compilerHost.writeFile = originalWriteFile;
125254
125339
  return builderProgram;
125255
125340
  }
125256
125341
  function createNewProgram(hasInvalidatedResolution) {
@@ -125728,19 +125813,20 @@ var ts;
125728
125813
  */
125729
125814
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
125730
125815
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
125731
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
125732
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
125733
- UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
125734
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
125735
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
125736
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
125737
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
125738
- UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
125816
+ UpToDateStatusType[UpToDateStatusType["ErrorReadingFile"] = 5] = "ErrorReadingFile";
125817
+ UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 6] = "OutOfDateWithSelf";
125818
+ UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 7] = "OutOfDateWithUpstream";
125819
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 8] = "OutOfDateBuildInfo";
125820
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 9] = "UpstreamOutOfDate";
125821
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 10] = "UpstreamBlocked";
125822
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 11] = "ComputingUpstream";
125823
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 12] = "TsVersionOutputOfDate";
125824
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 13] = "UpToDateWithInputFileText";
125739
125825
  /**
125740
125826
  * Projects with no outputs (i.e. "solution" files)
125741
125827
  */
125742
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
125743
- UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
125828
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 14] = "ContainerOnly";
125829
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 15] = "ForceBuild";
125744
125830
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
125745
125831
  function resolveConfigFileProjectName(project) {
125746
125832
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -126442,13 +126528,13 @@ var ts;
126442
126528
  var emitterDiagnostics = ts.createDiagnosticCollection();
126443
126529
  var emittedOutputs = new ts.Map();
126444
126530
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
126445
- var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
126531
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo || undefined;
126446
126532
  outputFiles.forEach(function (_a) {
126447
126533
  var _b, _c;
126448
126534
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
126449
126535
  emittedOutputs.set(toPath(state, name), name);
126450
126536
  if (buildInfo) {
126451
- if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) {
126537
+ 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)) {
126452
126538
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
126453
126539
  }
126454
126540
  setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags);
@@ -126741,8 +126827,7 @@ var ts;
126741
126827
  return existing.buildInfo || undefined;
126742
126828
  }
126743
126829
  var value = state.readFileWithCache(buildInfoPath);
126744
- var buildInfo = value ? ts.getBuildInfo(value) : undefined;
126745
- ts.Debug.assert(modifiedTime || !buildInfo);
126830
+ var buildInfo = value ? ts.getBuildInfo(buildInfoPath, value) : undefined;
126746
126831
  state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
126747
126832
  return buildInfo;
126748
126833
  }
@@ -126827,7 +126912,14 @@ var ts;
126827
126912
  missingOutputFileName: buildInfoPath
126828
126913
  };
126829
126914
  }
126830
- var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
126915
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime);
126916
+ if (!buildInfo) {
126917
+ // Error reading buildInfo
126918
+ return {
126919
+ type: ts.UpToDateStatusType.ErrorReadingFile,
126920
+ fileName: buildInfoPath
126921
+ };
126922
+ }
126831
126923
  if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
126832
126924
  return {
126833
126925
  type: ts.UpToDateStatusType.TsVersionOutputOfDate,
@@ -127485,6 +127577,8 @@ var ts;
127485
127577
  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));
127486
127578
  case ts.UpToDateStatusType.OutputMissing:
127487
127579
  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));
127580
+ case ts.UpToDateStatusType.ErrorReadingFile:
127581
+ 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));
127488
127582
  case ts.UpToDateStatusType.OutOfDateBuildInfo:
127489
127583
  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));
127490
127584
  case ts.UpToDateStatusType.UpToDate: