typescript 4.8.0-dev.20220809 → 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/tsc.js CHANGED
@@ -68,8 +68,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
68
68
  };
69
69
  var ts;
70
70
  (function (ts) {
71
- ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220809";
71
+ ts.versionMajorMinor = "4.9";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220811";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -78,24 +78,25 @@ var ts;
78
78
  undefined;
79
79
  function tryGetNativeMap() {
80
80
  var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
81
- return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
81
+ var constructor = typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
82
+ if (!constructor) {
83
+ throw new Error("No compatible Map implementation found.");
84
+ }
85
+ return constructor;
82
86
  }
83
87
  NativeCollections.tryGetNativeMap = tryGetNativeMap;
84
88
  function tryGetNativeSet() {
85
89
  var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
86
- return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
90
+ var constructor = typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
91
+ if (!constructor) {
92
+ throw new Error("No compatible Set implementation found.");
93
+ }
94
+ return constructor;
87
95
  }
88
96
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
89
97
  })(NativeCollections || (NativeCollections = {}));
90
- ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
91
- ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
92
- function getCollectionImplementation(name, nativeFactory, shimFactory) {
93
- var _a;
94
- var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator);
95
- if (constructor)
96
- return constructor;
97
- throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");
98
- }
98
+ ts.Map = NativeCollections.tryGetNativeMap();
99
+ ts.Set = NativeCollections.tryGetNativeSet();
99
100
  })(ts || (ts = {}));
100
101
  var ts;
101
102
  (function (ts) {
@@ -759,15 +760,18 @@ var ts;
759
760
  function insertSorted(array, insert, compare, allowDuplicates) {
760
761
  if (array.length === 0) {
761
762
  array.push(insert);
762
- return;
763
+ return true;
763
764
  }
764
765
  var insertIndex = binarySearch(array, insert, identity, compare);
765
766
  if (insertIndex < 0) {
766
767
  array.splice(~insertIndex, 0, insert);
768
+ return true;
767
769
  }
768
- else if (allowDuplicates) {
770
+ if (allowDuplicates) {
769
771
  array.splice(insertIndex, 0, insert);
772
+ return true;
770
773
  }
774
+ return false;
771
775
  }
772
776
  ts.insertSorted = insertSorted;
773
777
  function sortAndDeduplicate(array, comparer, equalityComparer) {
@@ -5078,12 +5082,9 @@ var ts;
5078
5082
  }
5079
5083
  ts.getPathFromPathComponents = getPathFromPathComponents;
5080
5084
  function normalizeSlashes(path) {
5081
- var index = path.indexOf("\\");
5082
- if (index === -1) {
5083
- return path;
5084
- }
5085
- backslashRegExp.lastIndex = index;
5086
- return path.replace(backslashRegExp, ts.directorySeparator);
5085
+ return path.indexOf("\\") !== -1
5086
+ ? path.replace(backslashRegExp, ts.directorySeparator)
5087
+ : path;
5087
5088
  }
5088
5089
  ts.normalizeSlashes = normalizeSlashes;
5089
5090
  function reducePathComponents(components) {
@@ -6704,6 +6705,7 @@ var ts;
6704
6705
  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."),
6705
6706
  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"),
6706
6707
  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"),
6708
+ 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}'"),
6707
6709
  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}'"),
6708
6710
  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."),
6709
6711
  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."),
@@ -15279,20 +15281,16 @@ var ts;
15279
15281
  return getStringFromExpandedCharCodes(expandedCharCodes);
15280
15282
  }
15281
15283
  ts.base64decode = base64decode;
15284
+ function readJsonOrUndefined(path, hostOrText) {
15285
+ var jsonText = ts.isString(hostOrText) ? hostOrText : hostOrText.readFile(path);
15286
+ if (!jsonText)
15287
+ return undefined;
15288
+ var result = ts.parseConfigFileTextToJson(path, jsonText);
15289
+ return !result.error ? result.config : undefined;
15290
+ }
15291
+ ts.readJsonOrUndefined = readJsonOrUndefined;
15282
15292
  function readJson(path, host) {
15283
- try {
15284
- var jsonText = host.readFile(path);
15285
- if (!jsonText)
15286
- return {};
15287
- var result = ts.parseConfigFileTextToJson(path, jsonText);
15288
- if (result.error) {
15289
- return {};
15290
- }
15291
- return result.config;
15292
- }
15293
- catch (e) {
15294
- return {};
15295
- }
15293
+ return readJsonOrUndefined(path, host) || {};
15296
15294
  }
15297
15295
  ts.readJson = readJson;
15298
15296
  function directoryProbablyExists(directoryName, host) {
@@ -22352,9 +22350,10 @@ var ts;
22352
22350
  };
22353
22351
  var buildInfo_1;
22354
22352
  var getAndCacheBuildInfo_1 = function (getText) {
22353
+ var _a;
22355
22354
  if (buildInfo_1 === undefined) {
22356
22355
  var result = getText();
22357
- buildInfo_1 = result !== undefined ? ts.getBuildInfo(result) : false;
22356
+ buildInfo_1 = result !== undefined ? (_a = ts.getBuildInfo(node.buildInfoPath, result)) !== null && _a !== void 0 ? _a : false : false;
22358
22357
  }
22359
22358
  return buildInfo_1 || undefined;
22360
22359
  };
@@ -37498,6 +37497,9 @@ var ts;
37498
37497
  case 203:
37499
37498
  bindBindingElementFlow(node);
37500
37499
  break;
37500
+ case 164:
37501
+ bindParameterFlow(node);
37502
+ break;
37501
37503
  case 205:
37502
37504
  case 204:
37503
37505
  case 296:
@@ -38192,15 +38194,32 @@ var ts;
38192
38194
  }
38193
38195
  }
38194
38196
  function bindBindingElementFlow(node) {
38195
- if (ts.isBindingPattern(node.name)) {
38196
- bind(node.dotDotDotToken);
38197
- bind(node.propertyName);
38198
- bind(node.initializer);
38199
- bind(node.name);
38197
+ bind(node.dotDotDotToken);
38198
+ bind(node.propertyName);
38199
+ bindInitializer(node.initializer);
38200
+ bind(node.name);
38201
+ }
38202
+ function bindParameterFlow(node) {
38203
+ bindEach(node.modifiers);
38204
+ bind(node.dotDotDotToken);
38205
+ bind(node.questionToken);
38206
+ bind(node.type);
38207
+ bindInitializer(node.initializer);
38208
+ bind(node.name);
38209
+ }
38210
+ function bindInitializer(node) {
38211
+ if (!node) {
38212
+ return;
38200
38213
  }
38201
- else {
38202
- bindEachChild(node);
38214
+ var entryFlow = currentFlow;
38215
+ bind(node);
38216
+ if (entryFlow === unreachableFlow || entryFlow === currentFlow) {
38217
+ return;
38203
38218
  }
38219
+ var exitFlow = createBranchLabel();
38220
+ addAntecedent(exitFlow, entryFlow);
38221
+ addAntecedent(exitFlow, currentFlow);
38222
+ currentFlow = finishFlowLabel(exitFlow);
38204
38223
  }
38205
38224
  function bindJSDocTypeAlias(node) {
38206
38225
  bind(node.tagName);
@@ -40846,7 +40865,7 @@ var ts;
40846
40865
  if (unidirectional === void 0) { unidirectional = false; }
40847
40866
  source.forEach(function (sourceSymbol, id) {
40848
40867
  var targetSymbol = target.get(id);
40849
- target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
40868
+ target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : getMergedSymbol(sourceSymbol));
40850
40869
  });
40851
40870
  }
40852
40871
  function mergeModuleAugmentation(moduleName) {
@@ -46698,11 +46717,9 @@ var ts;
46698
46717
  return getReturnTypeOfSignature(getterSignature);
46699
46718
  }
46700
46719
  }
46701
- if (ts.isInJSFile(declaration)) {
46702
- var type_1 = getParameterTypeOfTypeTag(func, declaration);
46703
- if (type_1)
46704
- return type_1;
46705
- }
46720
+ var parameterTypeOfTypeTag = getParameterTypeOfTypeTag(func, declaration);
46721
+ if (parameterTypeOfTypeTag)
46722
+ return parameterTypeOfTypeTag;
46706
46723
  var type = declaration.symbol.escapedName === "this" ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
46707
46724
  if (type) {
46708
46725
  return addOptionality(type, false, isOptional);
@@ -47207,8 +47224,8 @@ var ts;
47207
47224
  if (typeNode === undefined) {
47208
47225
  return useUnknownInCatchVariables ? unknownType : anyType;
47209
47226
  }
47210
- var type_2 = getTypeOfNode(typeNode);
47211
- return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
47227
+ var type_1 = getTypeOfNode(typeNode);
47228
+ return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
47212
47229
  }
47213
47230
  if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
47214
47231
  if (!declaration.statements.length) {
@@ -47405,11 +47422,11 @@ var ts;
47405
47422
  return errorType;
47406
47423
  }
47407
47424
  var exportEquals = getMergedSymbol(symbol.exports.get("export="));
47408
- var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
47425
+ var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
47409
47426
  if (!popTypeResolution()) {
47410
47427
  return reportCircularityError(symbol);
47411
47428
  }
47412
- return type_3;
47429
+ return type_2;
47413
47430
  }
47414
47431
  }
47415
47432
  var type = createObjectType(16, symbol);
@@ -49335,10 +49352,10 @@ var ts;
49335
49352
  var baseTypes = [];
49336
49353
  var different = false;
49337
49354
  for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
49338
- var type_4 = types_7[_i];
49339
- var baseType = getBaseConstraint(type_4);
49355
+ var type_3 = types_7[_i];
49356
+ var baseType = getBaseConstraint(type_3);
49340
49357
  if (baseType) {
49341
- if (baseType !== type_4) {
49358
+ if (baseType !== type_3) {
49342
49359
  different = true;
49343
49360
  }
49344
49361
  baseTypes.push(baseType);
@@ -50019,7 +50036,10 @@ var ts;
50019
50036
  continue;
50020
50037
  }
50021
50038
  }
50022
- result.push(getSignatureFromDeclaration(decl));
50039
+ result.push((!ts.isFunctionExpressionOrArrowFunction(decl) &&
50040
+ !ts.isObjectLiteralMethod(decl) &&
50041
+ getSignatureOfTypeTag(decl)) ||
50042
+ getSignatureFromDeclaration(decl));
50023
50043
  }
50024
50044
  return result;
50025
50045
  }
@@ -50050,7 +50070,7 @@ var ts;
50050
50070
  else {
50051
50071
  var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
50052
50072
  var jsdocPredicate = void 0;
50053
- if (!type && ts.isInJSFile(signature.declaration)) {
50073
+ if (!type) {
50054
50074
  var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
50055
50075
  if (jsdocSignature && signature !== jsdocSignature) {
50056
50076
  jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
@@ -53643,14 +53663,13 @@ var ts;
53643
53663
  return false;
53644
53664
  }
53645
53665
  function isContextSensitiveFunctionLikeDeclaration(node) {
53646
- return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
53647
- (ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
53666
+ return ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node);
53648
53667
  }
53649
53668
  function hasContextSensitiveReturnExpression(node) {
53650
53669
  return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 && isContextSensitive(node.body);
53651
53670
  }
53652
53671
  function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
53653
- return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
53672
+ return (ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
53654
53673
  isContextSensitiveFunctionLikeDeclaration(func);
53655
53674
  }
53656
53675
  function getTypeWithoutSignatures(type) {
@@ -61414,8 +61433,11 @@ var ts;
61414
61433
  case 1:
61415
61434
  case 6:
61416
61435
  case 3:
61417
- var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
61418
61436
  case 2:
61437
+ var valueDeclaration = void 0;
61438
+ if (kind !== 2) {
61439
+ valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
61440
+ }
61419
61441
  valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration);
61420
61442
  var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration);
61421
61443
  return annotated ? getTypeFromTypeNode(annotated) : undefined;
@@ -61824,9 +61846,18 @@ var ts;
61824
61846
  if (!isErrorType(intrinsicClassAttribs)) {
61825
61847
  var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
61826
61848
  var hostClassType = getReturnTypeOfSignature(sig);
61827
- apparentAttributesType = intersectTypes(typeParams
61828
- ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
61829
- : intrinsicClassAttribs, apparentAttributesType);
61849
+ var libraryManagedAttributeType = void 0;
61850
+ if (typeParams && typeParams.length === 1) {
61851
+ var inferredArgs = fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context));
61852
+ libraryManagedAttributeType = instantiateType(intrinsicClassAttribs, createTypeMapper(typeParams, inferredArgs));
61853
+ }
61854
+ else if (typeParams)
61855
+ libraryManagedAttributeType = undefined;
61856
+ else
61857
+ libraryManagedAttributeType = intrinsicClassAttribs;
61858
+ if (libraryManagedAttributeType) {
61859
+ apparentAttributesType = intersectTypes(libraryManagedAttributeType, apparentAttributesType);
61860
+ }
61830
61861
  }
61831
61862
  var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
61832
61863
  if (!isErrorType(intrinsicAttribs)) {
@@ -65043,11 +65074,13 @@ var ts;
65043
65074
  return false;
65044
65075
  }
65045
65076
  var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
65046
- ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
65077
+ (ts.isVariableDeclaration(node) || ts.isPropertyAssignment(node)) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
65047
65078
  undefined;
65048
65079
  if (func) {
65049
65080
  if (ts.getJSDocClassTag(node))
65050
65081
  return true;
65082
+ if (ts.isPropertyAssignment(ts.walkUpParenthesizedExpressions(func.parent)))
65083
+ return false;
65051
65084
  var symbol = getSymbolOfNode(func);
65052
65085
  return !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.members) === null || _a === void 0 ? void 0 : _a.size);
65053
65086
  }
@@ -65279,8 +65312,8 @@ var ts;
65279
65312
  if (hasDefaultOnly && type && !isErrorType(type)) {
65280
65313
  var synthType = type;
65281
65314
  if (!synthType.defaultOnlyType) {
65282
- var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
65283
- synthType.defaultOnlyType = type_5;
65315
+ var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
65316
+ synthType.defaultOnlyType = type_4;
65284
65317
  }
65285
65318
  return synthType.defaultOnlyType;
65286
65319
  }
@@ -73404,6 +73437,12 @@ var ts;
73404
73437
  return resolveJSDocMemberName(name, false, getSymbolOfNode(container));
73405
73438
  }
73406
73439
  }
73440
+ if (result && isJSDoc_1) {
73441
+ var container = ts.getJSDocHost(name);
73442
+ if (container && ts.isEnumMember(container) && container === result.valueDeclaration) {
73443
+ return resolveEntityName(name, meaning, true, true, ts.getSourceFileOfNode(container)) || result;
73444
+ }
73445
+ }
73407
73446
  return result;
73408
73447
  }
73409
73448
  else if (ts.isPrivateIdentifier(name)) {
@@ -88487,6 +88526,12 @@ var ts;
88487
88526
  case 265:
88488
88527
  ts.Debug.assert(importVariableName !== undefined);
88489
88528
  statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
88529
+ if (ts.hasSyntacticModifier(entry, 1)) {
88530
+ statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction, undefined, [
88531
+ factory.createStringLiteral(ts.idText(importVariableName)),
88532
+ parameterName,
88533
+ ])));
88534
+ }
88490
88535
  break;
88491
88536
  case 272:
88492
88537
  ts.Debug.assert(importVariableName !== undefined);
@@ -90728,8 +90773,12 @@ var ts;
90728
90773
  }
90729
90774
  var previousNeedsDeclare = needsDeclare;
90730
90775
  switch (input.kind) {
90731
- case 259:
90732
- return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
90776
+ case 259: {
90777
+ needsDeclare = false;
90778
+ var clean = cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
90779
+ needsDeclare = previousNeedsDeclare;
90780
+ return clean;
90781
+ }
90733
90782
  case 258: {
90734
90783
  return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
90735
90784
  }
@@ -92038,8 +92087,8 @@ var ts;
92038
92087
  return JSON.stringify(buildInfo);
92039
92088
  }
92040
92089
  ts.getBuildInfoText = getBuildInfoText;
92041
- function getBuildInfo(buildInfoText) {
92042
- return JSON.parse(buildInfoText);
92090
+ function getBuildInfo(buildInfoFile, buildInfoText) {
92091
+ return ts.readJsonOrUndefined(buildInfoFile, buildInfoText);
92043
92092
  }
92044
92093
  ts.getBuildInfo = getBuildInfo;
92045
92094
  ts.notImplementedResolver = {
@@ -92113,17 +92162,16 @@ var ts;
92113
92162
  var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
92114
92163
  var buildInfo;
92115
92164
  if (host.getBuildInfo) {
92116
- var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
92117
- if (!hostBuildInfo)
92118
- return buildInfoPath;
92119
- buildInfo = hostBuildInfo;
92165
+ buildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
92120
92166
  }
92121
92167
  else {
92122
92168
  var buildInfoText = host.readFile(buildInfoPath);
92123
92169
  if (!buildInfoText)
92124
92170
  return buildInfoPath;
92125
- buildInfo = getBuildInfo(buildInfoText);
92171
+ buildInfo = getBuildInfo(buildInfoPath, buildInfoText);
92126
92172
  }
92173
+ if (!buildInfo)
92174
+ return buildInfoPath;
92127
92175
  if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
92128
92176
  return buildInfoPath;
92129
92177
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
@@ -96367,7 +96415,15 @@ var ts;
96367
96415
  return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
96368
96416
  }
96369
96417
  function getCachedFileSystemEntriesForBaseDir(path) {
96370
- return getCachedFileSystemEntries(ts.getDirectoryPath(path));
96418
+ var entries = getCachedFileSystemEntries(ts.getDirectoryPath(path));
96419
+ if (!entries) {
96420
+ return entries;
96421
+ }
96422
+ if (!entries.sortedAndCanonicalizedFiles) {
96423
+ entries.sortedAndCanonicalizedFiles = entries.files.map(getCanonicalFileName).sort();
96424
+ entries.sortedAndCanonicalizedDirectories = entries.directories.map(getCanonicalFileName).sort();
96425
+ }
96426
+ return entries;
96371
96427
  }
96372
96428
  function getBaseNameOfFileName(fileName) {
96373
96429
  return ts.getBaseFileName(ts.normalizePath(fileName));
@@ -96402,21 +96458,9 @@ var ts;
96402
96458
  return undefined;
96403
96459
  }
96404
96460
  }
96405
- function fileNameEqual(name1, name2) {
96406
- return getCanonicalFileName(name1) === getCanonicalFileName(name2);
96407
- }
96408
96461
  function hasEntry(entries, name) {
96409
- return ts.some(entries, function (file) { return fileNameEqual(file, name); });
96410
- }
96411
- function updateFileSystemEntry(entries, baseName, isValid) {
96412
- if (hasEntry(entries, baseName)) {
96413
- if (!isValid) {
96414
- return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
96415
- }
96416
- }
96417
- else if (isValid) {
96418
- return entries.push(baseName);
96419
- }
96462
+ var index = ts.binarySearch(entries, name, ts.identity, ts.compareStringsCaseSensitive);
96463
+ return index >= 0;
96420
96464
  }
96421
96465
  function writeFile(fileName, data, writeByteOrderMark) {
96422
96466
  var path = toPath(fileName);
@@ -96429,7 +96473,7 @@ var ts;
96429
96473
  function fileExists(fileName) {
96430
96474
  var path = toPath(fileName);
96431
96475
  var result = getCachedFileSystemEntriesForBaseDir(path);
96432
- return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
96476
+ return result && hasEntry(result.sortedAndCanonicalizedFiles, getCanonicalFileName(getBaseNameOfFileName(fileName))) ||
96433
96477
  host.fileExists(fileName);
96434
96478
  }
96435
96479
  function directoryExists(dirPath) {
@@ -96439,9 +96483,13 @@ var ts;
96439
96483
  function createDirectory(dirPath) {
96440
96484
  var path = toPath(dirPath);
96441
96485
  var result = getCachedFileSystemEntriesForBaseDir(path);
96442
- var baseFileName = getBaseNameOfFileName(dirPath);
96443
96486
  if (result) {
96444
- updateFileSystemEntry(result.directories, baseFileName, true);
96487
+ var baseName = getBaseNameOfFileName(dirPath);
96488
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
96489
+ var canonicalizedDirectories = result.sortedAndCanonicalizedDirectories;
96490
+ if (ts.insertSorted(canonicalizedDirectories, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
96491
+ result.directories.push(baseName);
96492
+ }
96445
96493
  }
96446
96494
  host.createDirectory(dirPath);
96447
96495
  }
@@ -96505,7 +96553,7 @@ var ts;
96505
96553
  fileExists: host.fileExists(fileOrDirectoryPath),
96506
96554
  directoryExists: host.directoryExists(fileOrDirectoryPath)
96507
96555
  };
96508
- if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
96556
+ if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
96509
96557
  clearCache();
96510
96558
  }
96511
96559
  else {
@@ -96523,7 +96571,21 @@ var ts;
96523
96571
  }
96524
96572
  }
96525
96573
  function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
96526
- updateFileSystemEntry(parentResult.files, baseName, fileExists);
96574
+ var canonicalizedFiles = parentResult.sortedAndCanonicalizedFiles;
96575
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
96576
+ if (fileExists) {
96577
+ if (ts.insertSorted(canonicalizedFiles, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
96578
+ parentResult.files.push(baseName);
96579
+ }
96580
+ }
96581
+ else {
96582
+ var sortedIndex = ts.binarySearch(canonicalizedFiles, canonicalizedBaseName, ts.identity, ts.compareStringsCaseSensitive);
96583
+ if (sortedIndex >= 0) {
96584
+ canonicalizedFiles.splice(sortedIndex, 1);
96585
+ var unsortedIndex = parentResult.files.findIndex(function (entry) { return getCanonicalFileName(entry) === canonicalizedBaseName; });
96586
+ parentResult.files.splice(unsortedIndex, 1);
96587
+ }
96588
+ }
96527
96589
  }
96528
96590
  function clearCache() {
96529
96591
  cachedReadDirectoryResult.clear();
@@ -103677,18 +103739,14 @@ var ts;
103677
103739
  var buildInfo;
103678
103740
  if (host.getBuildInfo) {
103679
103741
  buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
103680
- if (!buildInfo)
103681
- return undefined;
103682
103742
  }
103683
103743
  else {
103684
103744
  var content = host.readFile(buildInfoPath);
103685
103745
  if (!content)
103686
103746
  return undefined;
103687
- buildInfo = ts.getBuildInfo(content);
103747
+ buildInfo = ts.getBuildInfo(buildInfoPath, content);
103688
103748
  }
103689
- if (buildInfo.version !== ts.version)
103690
- return undefined;
103691
- if (!buildInfo.program)
103749
+ if (!buildInfo || buildInfo.version !== ts.version || !buildInfo.program)
103692
103750
  return undefined;
103693
103751
  return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
103694
103752
  }
@@ -103901,7 +103959,8 @@ var ts;
103901
103959
  }
103902
103960
  }
103903
103961
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
103904
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
103962
+ var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
103963
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
103905
103964
  if (hasChangedConfigFileParsingErrors) {
103906
103965
  if (reportFileChangeDetectedOnCreateProgram) {
103907
103966
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -103920,6 +103979,11 @@ var ts;
103920
103979
  if (host.afterProgramCreate && program !== builderProgram) {
103921
103980
  host.afterProgramCreate(builderProgram);
103922
103981
  }
103982
+ compilerHost.readFile = originalReadFile;
103983
+ compilerHost.fileExists = originalFileExists;
103984
+ compilerHost.directoryExists = originalDirectoryExists;
103985
+ compilerHost.createDirectory = originalCreateDirectory;
103986
+ compilerHost.writeFile = originalWriteFile;
103923
103987
  return builderProgram;
103924
103988
  }
103925
103989
  function createNewProgram(hasInvalidatedResolution) {
@@ -104339,16 +104403,17 @@ var ts;
104339
104403
  UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes";
104340
104404
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
104341
104405
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
104342
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
104343
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
104344
- UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
104345
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
104346
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
104347
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
104348
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
104349
- UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
104350
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
104351
- UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
104406
+ UpToDateStatusType[UpToDateStatusType["ErrorReadingFile"] = 5] = "ErrorReadingFile";
104407
+ UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 6] = "OutOfDateWithSelf";
104408
+ UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 7] = "OutOfDateWithUpstream";
104409
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 8] = "OutOfDateBuildInfo";
104410
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 9] = "UpstreamOutOfDate";
104411
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 10] = "UpstreamBlocked";
104412
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 11] = "ComputingUpstream";
104413
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 12] = "TsVersionOutputOfDate";
104414
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 13] = "UpToDateWithInputFileText";
104415
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 14] = "ContainerOnly";
104416
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 15] = "ForceBuild";
104352
104417
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
104353
104418
  function resolveConfigFileProjectName(project) {
104354
104419
  if (ts.fileExtensionIs(project, ".json")) {
@@ -105013,13 +105078,13 @@ var ts;
105013
105078
  var emitterDiagnostics = ts.createDiagnosticCollection();
105014
105079
  var emittedOutputs = new ts.Map();
105015
105080
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
105016
- var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
105081
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo || undefined;
105017
105082
  outputFiles.forEach(function (_a) {
105018
105083
  var _b, _c;
105019
105084
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
105020
105085
  emittedOutputs.set(toPath(state, name), name);
105021
105086
  if (buildInfo) {
105022
- if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) {
105087
+ 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)) {
105023
105088
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
105024
105089
  }
105025
105090
  setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags);
@@ -105302,8 +105367,7 @@ var ts;
105302
105367
  return existing.buildInfo || undefined;
105303
105368
  }
105304
105369
  var value = state.readFileWithCache(buildInfoPath);
105305
- var buildInfo = value ? ts.getBuildInfo(value) : undefined;
105306
- ts.Debug.assert(modifiedTime || !buildInfo);
105370
+ var buildInfo = value ? ts.getBuildInfo(buildInfoPath, value) : undefined;
105307
105371
  state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
105308
105372
  return buildInfo;
105309
105373
  }
@@ -105381,7 +105445,13 @@ var ts;
105381
105445
  missingOutputFileName: buildInfoPath
105382
105446
  };
105383
105447
  }
105384
- var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
105448
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime);
105449
+ if (!buildInfo) {
105450
+ return {
105451
+ type: ts.UpToDateStatusType.ErrorReadingFile,
105452
+ fileName: buildInfoPath
105453
+ };
105454
+ }
105385
105455
  if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
105386
105456
  return {
105387
105457
  type: ts.UpToDateStatusType.TsVersionOutputOfDate,
@@ -105989,6 +106059,8 @@ var ts;
105989
106059
  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));
105990
106060
  case ts.UpToDateStatusType.OutputMissing:
105991
106061
  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));
106062
+ case ts.UpToDateStatusType.ErrorReadingFile:
106063
+ 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));
105992
106064
  case ts.UpToDateStatusType.OutOfDateBuildInfo:
105993
106065
  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));
105994
106066
  case ts.UpToDateStatusType.UpToDate: