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.
@@ -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.20220809";
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)) {
@@ -77758,12 +77789,15 @@ var ts;
77758
77789
  return false;
77759
77790
  }
77760
77791
  var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
77761
- 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 :
77762
77793
  undefined;
77763
77794
  if (func) {
77764
- // 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.
77765
77796
  if (ts.getJSDocClassTag(node))
77766
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;
77767
77801
  // If the symbol of the node has members, treat it like a constructor.
77768
77802
  var symbol = getSymbolOfNode(func);
77769
77803
  return !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.members) === null || _a === void 0 ? void 0 : _a.size);
@@ -78011,8 +78045,8 @@ var ts;
78011
78045
  if (hasDefaultOnly && type && !isErrorType(type)) {
78012
78046
  var synthType = type;
78013
78047
  if (!synthType.defaultOnlyType) {
78014
- var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78015
- synthType.defaultOnlyType = type_5;
78048
+ var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78049
+ synthType.defaultOnlyType = type_4;
78016
78050
  }
78017
78051
  return synthType.defaultOnlyType;
78018
78052
  }
@@ -87349,6 +87383,12 @@ var ts;
87349
87383
  return resolveJSDocMemberName(name, /*ignoreErrors*/ false, getSymbolOfNode(container));
87350
87384
  }
87351
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
+ }
87352
87392
  return result;
87353
87393
  }
87354
87394
  else if (ts.isPrivateIdentifier(name)) {
@@ -107510,6 +107550,13 @@ var ts;
107510
107550
  ts.Debug.assert(importVariableName !== undefined);
107511
107551
  // save import into the local
107512
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
+ }
107513
107560
  break;
107514
107561
  case 272 /* ExportDeclaration */:
107515
107562
  ts.Debug.assert(importVariableName !== undefined);
@@ -110352,8 +110399,12 @@ var ts;
110352
110399
  }
110353
110400
  var previousNeedsDeclare = needsDeclare;
110354
110401
  switch (input.kind) {
110355
- case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all
110356
- 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
+ }
110357
110408
  case 258 /* InterfaceDeclaration */: {
110358
110409
  return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
110359
110410
  }
@@ -111857,8 +111908,8 @@ var ts;
111857
111908
  }
111858
111909
  ts.getBuildInfoText = getBuildInfoText;
111859
111910
  /*@internal*/
111860
- function getBuildInfo(buildInfoText) {
111861
- return JSON.parse(buildInfoText);
111911
+ function getBuildInfo(buildInfoFile, buildInfoText) {
111912
+ return ts.readJsonOrUndefined(buildInfoFile, buildInfoText);
111862
111913
  }
111863
111914
  ts.getBuildInfo = getBuildInfo;
111864
111915
  /*@internal*/
@@ -111936,17 +111987,16 @@ var ts;
111936
111987
  var buildInfo;
111937
111988
  if (host.getBuildInfo) {
111938
111989
  // If host directly provides buildinfo we can get it directly. This allows host to cache the buildinfo
111939
- var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
111940
- if (!hostBuildInfo)
111941
- return buildInfoPath;
111942
- buildInfo = hostBuildInfo;
111990
+ buildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
111943
111991
  }
111944
111992
  else {
111945
111993
  var buildInfoText = host.readFile(buildInfoPath);
111946
111994
  if (!buildInfoText)
111947
111995
  return buildInfoPath;
111948
- buildInfo = getBuildInfo(buildInfoText);
111996
+ buildInfo = getBuildInfo(buildInfoPath, buildInfoText);
111949
111997
  }
111998
+ if (!buildInfo)
111999
+ return buildInfoPath;
111950
112000
  if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
111951
112001
  return buildInfoPath;
111952
112002
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
@@ -116604,7 +116654,16 @@ var ts;
116604
116654
  return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
116605
116655
  }
116606
116656
  function getCachedFileSystemEntriesForBaseDir(path) {
116607
- 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;
116608
116667
  }
116609
116668
  function getBaseNameOfFileName(fileName) {
116610
116669
  return ts.getBaseFileName(ts.normalizePath(fileName));
@@ -116647,21 +116706,10 @@ var ts;
116647
116706
  return undefined;
116648
116707
  }
116649
116708
  }
116650
- function fileNameEqual(name1, name2) {
116651
- return getCanonicalFileName(name1) === getCanonicalFileName(name2);
116652
- }
116653
116709
  function hasEntry(entries, name) {
116654
- return ts.some(entries, function (file) { return fileNameEqual(file, name); });
116655
- }
116656
- function updateFileSystemEntry(entries, baseName, isValid) {
116657
- if (hasEntry(entries, baseName)) {
116658
- if (!isValid) {
116659
- return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
116660
- }
116661
- }
116662
- else if (isValid) {
116663
- return entries.push(baseName);
116664
- }
116710
+ // Case-sensitive comparison since already canonicalized
116711
+ var index = ts.binarySearch(entries, name, ts.identity, ts.compareStringsCaseSensitive);
116712
+ return index >= 0;
116665
116713
  }
116666
116714
  function writeFile(fileName, data, writeByteOrderMark) {
116667
116715
  var path = toPath(fileName);
@@ -116674,7 +116722,7 @@ var ts;
116674
116722
  function fileExists(fileName) {
116675
116723
  var path = toPath(fileName);
116676
116724
  var result = getCachedFileSystemEntriesForBaseDir(path);
116677
- return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
116725
+ return result && hasEntry(result.sortedAndCanonicalizedFiles, getCanonicalFileName(getBaseNameOfFileName(fileName))) ||
116678
116726
  host.fileExists(fileName);
116679
116727
  }
116680
116728
  function directoryExists(dirPath) {
@@ -116684,9 +116732,14 @@ var ts;
116684
116732
  function createDirectory(dirPath) {
116685
116733
  var path = toPath(dirPath);
116686
116734
  var result = getCachedFileSystemEntriesForBaseDir(path);
116687
- var baseFileName = getBaseNameOfFileName(dirPath);
116688
116735
  if (result) {
116689
- 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
+ }
116690
116743
  }
116691
116744
  host.createDirectory(dirPath);
116692
116745
  }
@@ -116755,7 +116808,7 @@ var ts;
116755
116808
  fileExists: host.fileExists(fileOrDirectoryPath),
116756
116809
  directoryExists: host.directoryExists(fileOrDirectoryPath)
116757
116810
  };
116758
- if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
116811
+ if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
116759
116812
  // Folder added or removed, clear the cache instead of updating the folder and its structure
116760
116813
  clearCache();
116761
116814
  }
@@ -116775,7 +116828,23 @@ var ts;
116775
116828
  }
116776
116829
  }
116777
116830
  function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
116778
- 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
+ }
116779
116848
  }
116780
116849
  function clearCache() {
116781
116850
  cachedReadDirectoryResult.clear();
@@ -125013,18 +125082,14 @@ var ts;
125013
125082
  if (host.getBuildInfo) {
125014
125083
  // host provides buildinfo, get it from there. This allows host to cache it
125015
125084
  buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
125016
- if (!buildInfo)
125017
- return undefined;
125018
125085
  }
125019
125086
  else {
125020
125087
  var content = host.readFile(buildInfoPath);
125021
125088
  if (!content)
125022
125089
  return undefined;
125023
- buildInfo = ts.getBuildInfo(content);
125090
+ buildInfo = ts.getBuildInfo(buildInfoPath, content);
125024
125091
  }
125025
- if (buildInfo.version !== ts.version)
125026
- return undefined;
125027
- if (!buildInfo.program)
125092
+ if (!buildInfo || buildInfo.version !== ts.version || !buildInfo.program)
125028
125093
  return undefined;
125029
125094
  return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
125030
125095
  }
@@ -125246,7 +125311,8 @@ var ts;
125246
125311
  }
125247
125312
  // All resolutions are invalid if user provided resolutions
125248
125313
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
125249
- 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)) {
125250
125316
  if (hasChangedConfigFileParsingErrors) {
125251
125317
  if (reportFileChangeDetectedOnCreateProgram) {
125252
125318
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -125265,6 +125331,11 @@ var ts;
125265
125331
  if (host.afterProgramCreate && program !== builderProgram) {
125266
125332
  host.afterProgramCreate(builderProgram);
125267
125333
  }
125334
+ compilerHost.readFile = originalReadFile;
125335
+ compilerHost.fileExists = originalFileExists;
125336
+ compilerHost.directoryExists = originalDirectoryExists;
125337
+ compilerHost.createDirectory = originalCreateDirectory;
125338
+ compilerHost.writeFile = originalWriteFile;
125268
125339
  return builderProgram;
125269
125340
  }
125270
125341
  function createNewProgram(hasInvalidatedResolution) {
@@ -125742,19 +125813,20 @@ var ts;
125742
125813
  */
125743
125814
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
125744
125815
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
125745
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
125746
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
125747
- UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
125748
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
125749
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
125750
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
125751
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
125752
- 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";
125753
125825
  /**
125754
125826
  * Projects with no outputs (i.e. "solution" files)
125755
125827
  */
125756
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
125757
- UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
125828
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 14] = "ContainerOnly";
125829
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 15] = "ForceBuild";
125758
125830
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
125759
125831
  function resolveConfigFileProjectName(project) {
125760
125832
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -126456,13 +126528,13 @@ var ts;
126456
126528
  var emitterDiagnostics = ts.createDiagnosticCollection();
126457
126529
  var emittedOutputs = new ts.Map();
126458
126530
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
126459
- var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
126531
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo || undefined;
126460
126532
  outputFiles.forEach(function (_a) {
126461
126533
  var _b, _c;
126462
126534
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
126463
126535
  emittedOutputs.set(toPath(state, name), name);
126464
126536
  if (buildInfo) {
126465
- 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)) {
126466
126538
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
126467
126539
  }
126468
126540
  setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags);
@@ -126755,8 +126827,7 @@ var ts;
126755
126827
  return existing.buildInfo || undefined;
126756
126828
  }
126757
126829
  var value = state.readFileWithCache(buildInfoPath);
126758
- var buildInfo = value ? ts.getBuildInfo(value) : undefined;
126759
- ts.Debug.assert(modifiedTime || !buildInfo);
126830
+ var buildInfo = value ? ts.getBuildInfo(buildInfoPath, value) : undefined;
126760
126831
  state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
126761
126832
  return buildInfo;
126762
126833
  }
@@ -126841,7 +126912,14 @@ var ts;
126841
126912
  missingOutputFileName: buildInfoPath
126842
126913
  };
126843
126914
  }
126844
- 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
+ }
126845
126923
  if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
126846
126924
  return {
126847
126925
  type: ts.UpToDateStatusType.TsVersionOutputOfDate,
@@ -127499,6 +127577,8 @@ var ts;
127499
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));
127500
127578
  case ts.UpToDateStatusType.OutputMissing:
127501
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));
127502
127582
  case ts.UpToDateStatusType.OutOfDateBuildInfo:
127503
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));
127504
127584
  case ts.UpToDateStatusType.UpToDate: