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.
@@ -91,210 +91,15 @@ var __extends = (this && this.__extends) || (function () {
91
91
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
92
92
  };
93
93
  })();
94
- /* @internal */
95
- var ts;
96
- (function (ts) {
97
- function createMapData() {
98
- var sentinel = {};
99
- sentinel.prev = sentinel;
100
- return { head: sentinel, tail: sentinel, size: 0 };
101
- }
102
- function createMapEntry(key, value) {
103
- return { key: key, value: value, next: undefined, prev: undefined };
104
- }
105
- function sameValueZero(x, y) {
106
- // Treats -0 === 0 and NaN === NaN
107
- return x === y || x !== x && y !== y;
108
- }
109
- function getPrev(entry) {
110
- var prev = entry.prev;
111
- // Entries without a 'prev' have been removed from the map.
112
- // An entry whose 'prev' points to itself is the head of the list and is invalid here.
113
- if (!prev || prev === entry)
114
- throw new Error("Illegal state");
115
- return prev;
116
- }
117
- function getNext(entry) {
118
- while (entry) {
119
- // Entries without a 'prev' have been removed from the map. Their 'next'
120
- // pointer should point to the previous entry prior to deletion and
121
- // that entry should be skipped to resume iteration.
122
- var skipNext = !entry.prev;
123
- entry = entry.next;
124
- if (skipNext) {
125
- continue;
126
- }
127
- return entry;
128
- }
129
- }
130
- function getEntry(data, key) {
131
- // We walk backwards from 'tail' to prioritize recently added entries.
132
- // We skip 'head' because it is an empty entry used to track iteration start.
133
- for (var entry = data.tail; entry !== data.head; entry = getPrev(entry)) {
134
- if (sameValueZero(entry.key, key)) {
135
- return entry;
136
- }
137
- }
138
- }
139
- function addOrUpdateEntry(data, key, value) {
140
- var existing = getEntry(data, key);
141
- if (existing) {
142
- existing.value = value;
143
- return;
144
- }
145
- var entry = createMapEntry(key, value);
146
- entry.prev = data.tail;
147
- data.tail.next = entry;
148
- data.tail = entry;
149
- data.size++;
150
- return entry;
151
- }
152
- function deleteEntry(data, key) {
153
- // We walk backwards from 'tail' to prioritize recently added entries.
154
- // We skip 'head' because it is an empty entry used to track iteration start.
155
- for (var entry = data.tail; entry !== data.head; entry = getPrev(entry)) {
156
- // all entries in the map should have a 'prev' pointer.
157
- if (entry.prev === undefined)
158
- throw new Error("Illegal state");
159
- if (sameValueZero(entry.key, key)) {
160
- if (entry.next) {
161
- entry.next.prev = entry.prev;
162
- }
163
- else {
164
- // an entry in the map without a 'next' pointer must be the 'tail'.
165
- if (data.tail !== entry)
166
- throw new Error("Illegal state");
167
- data.tail = entry.prev;
168
- }
169
- entry.prev.next = entry.next;
170
- entry.next = entry.prev;
171
- entry.prev = undefined;
172
- data.size--;
173
- return entry;
174
- }
175
- }
176
- }
177
- function clearEntries(data) {
178
- var node = data.tail;
179
- while (node !== data.head) {
180
- var prev = getPrev(node);
181
- node.next = data.head;
182
- node.prev = undefined;
183
- node = prev;
184
- }
185
- data.head.next = undefined;
186
- data.tail = data.head;
187
- data.size = 0;
188
- }
189
- function forEachEntry(data, action) {
190
- var entry = data.head;
191
- while (entry) {
192
- entry = getNext(entry);
193
- if (entry) {
194
- action(entry.value, entry.key);
195
- }
196
- }
197
- }
198
- function forEachIteration(iterator, action) {
199
- if (iterator) {
200
- for (var step = iterator.next(); !step.done; step = iterator.next()) {
201
- action(step.value);
202
- }
203
- }
204
- }
205
- function createIteratorData(data, selector) {
206
- return { current: data.head, selector: selector };
207
- }
208
- function iteratorNext(data) {
209
- // Navigate to the next entry.
210
- data.current = getNext(data.current);
211
- if (data.current) {
212
- return { value: data.selector(data.current.key, data.current.value), done: false };
213
- }
214
- else {
215
- return { value: undefined, done: true };
216
- }
217
- }
218
- /* @internal */
219
- var ShimCollections;
220
- (function (ShimCollections) {
221
- function createMapShim(getIterator) {
222
- var MapIterator = /** @class */ (function () {
223
- function MapIterator(data, selector) {
224
- this._data = createIteratorData(data, selector);
225
- }
226
- MapIterator.prototype.next = function () { return iteratorNext(this._data); };
227
- return MapIterator;
228
- }());
229
- return /** @class */ (function () {
230
- function Map(iterable) {
231
- var _this = this;
232
- this._mapData = createMapData();
233
- forEachIteration(getIterator(iterable), function (_a) {
234
- var key = _a[0], value = _a[1];
235
- return _this.set(key, value);
236
- });
237
- }
238
- Object.defineProperty(Map.prototype, "size", {
239
- get: function () { return this._mapData.size; },
240
- enumerable: false,
241
- configurable: true
242
- });
243
- Map.prototype.get = function (key) { var _a; return (_a = getEntry(this._mapData, key)) === null || _a === void 0 ? void 0 : _a.value; };
244
- Map.prototype.set = function (key, value) { return addOrUpdateEntry(this._mapData, key, value), this; };
245
- Map.prototype.has = function (key) { return !!getEntry(this._mapData, key); };
246
- Map.prototype.delete = function (key) { return !!deleteEntry(this._mapData, key); };
247
- Map.prototype.clear = function () { clearEntries(this._mapData); };
248
- Map.prototype.keys = function () { return new MapIterator(this._mapData, function (key, _value) { return key; }); };
249
- Map.prototype.values = function () { return new MapIterator(this._mapData, function (_key, value) { return value; }); };
250
- Map.prototype.entries = function () { return new MapIterator(this._mapData, function (key, value) { return [key, value]; }); };
251
- Map.prototype.forEach = function (action) { forEachEntry(this._mapData, action); };
252
- return Map;
253
- }());
254
- }
255
- ShimCollections.createMapShim = createMapShim;
256
- function createSetShim(getIterator) {
257
- var SetIterator = /** @class */ (function () {
258
- function SetIterator(data, selector) {
259
- this._data = createIteratorData(data, selector);
260
- }
261
- SetIterator.prototype.next = function () { return iteratorNext(this._data); };
262
- return SetIterator;
263
- }());
264
- return /** @class */ (function () {
265
- function Set(iterable) {
266
- var _this = this;
267
- this._mapData = createMapData();
268
- forEachIteration(getIterator(iterable), function (value) { return _this.add(value); });
269
- }
270
- Object.defineProperty(Set.prototype, "size", {
271
- get: function () { return this._mapData.size; },
272
- enumerable: false,
273
- configurable: true
274
- });
275
- Set.prototype.add = function (value) { return addOrUpdateEntry(this._mapData, value, value), this; };
276
- Set.prototype.has = function (value) { return !!getEntry(this._mapData, value); };
277
- Set.prototype.delete = function (value) { return !!deleteEntry(this._mapData, value); };
278
- Set.prototype.clear = function () { clearEntries(this._mapData); };
279
- Set.prototype.keys = function () { return new SetIterator(this._mapData, function (key, _value) { return key; }); };
280
- Set.prototype.values = function () { return new SetIterator(this._mapData, function (_key, value) { return value; }); };
281
- Set.prototype.entries = function () { return new SetIterator(this._mapData, function (key, value) { return [key, value]; }); };
282
- Set.prototype.forEach = function (action) { forEachEntry(this._mapData, action); };
283
- return Set;
284
- }());
285
- }
286
- ShimCollections.createSetShim = createSetShim;
287
- })(ShimCollections = ts.ShimCollections || (ts.ShimCollections = {}));
288
- })(ts || (ts = {}));
289
94
  var ts;
290
95
  (function (ts) {
291
96
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
292
97
  // If changing the text in this section, be sure to test `configurePrerelease` too.
293
- ts.versionMajorMinor = "4.8";
98
+ ts.versionMajorMinor = "4.9";
294
99
  // The following is baselined as a literal template type without intervention
295
100
  /** The version of the TypeScript compiler release */
296
101
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220807";
102
+ ts.version = ts.versionMajorMinor + ".0-dev.20220811";
298
103
  /* @internal */
299
104
  var Comparison;
300
105
  (function (Comparison) {
@@ -316,7 +121,11 @@ var ts;
316
121
  // Internet Explorer's Map doesn't support iteration, so don't use it.
317
122
  var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
318
123
  // eslint-disable-next-line no-in-operator
319
- return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
124
+ var constructor = typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
125
+ if (!constructor) {
126
+ throw new Error("No compatible Map implementation found.");
127
+ }
128
+ return constructor;
320
129
  }
321
130
  NativeCollections.tryGetNativeMap = tryGetNativeMap;
322
131
  /**
@@ -326,23 +135,18 @@ var ts;
326
135
  // Internet Explorer's Set doesn't support iteration, so don't use it.
327
136
  var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
328
137
  // eslint-disable-next-line no-in-operator
329
- return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
138
+ var constructor = typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
139
+ if (!constructor) {
140
+ throw new Error("No compatible Set implementation found.");
141
+ }
142
+ return constructor;
330
143
  }
331
144
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
332
145
  })(NativeCollections || (NativeCollections = {}));
333
146
  /* @internal */
334
- ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
335
- /* @internal */
336
- ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
147
+ ts.Map = NativeCollections.tryGetNativeMap();
337
148
  /* @internal */
338
- function getCollectionImplementation(name, nativeFactory, shimFactory) {
339
- var _a;
340
- // NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it.
341
- var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator);
342
- if (constructor)
343
- return constructor;
344
- throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");
345
- }
149
+ ts.Set = NativeCollections.tryGetNativeSet();
346
150
  })(ts || (ts = {}));
347
151
  /* @internal */
348
152
  var ts;
@@ -1058,15 +862,18 @@ var ts;
1058
862
  function insertSorted(array, insert, compare, allowDuplicates) {
1059
863
  if (array.length === 0) {
1060
864
  array.push(insert);
1061
- return;
865
+ return true;
1062
866
  }
1063
867
  var insertIndex = binarySearch(array, insert, identity, compare);
1064
868
  if (insertIndex < 0) {
1065
869
  array.splice(~insertIndex, 0, insert);
870
+ return true;
1066
871
  }
1067
- else if (allowDuplicates) {
872
+ if (allowDuplicates) {
1068
873
  array.splice(insertIndex, 0, insert);
874
+ return true;
1069
875
  }
876
+ return false;
1070
877
  }
1071
878
  ts.insertSorted = insertSorted;
1072
879
  function sortAndDeduplicate(array, comparer, equalityComparer) {
@@ -8027,12 +7834,9 @@ var ts;
8027
7834
  * Normalize path separators, converting `\` into `/`.
8028
7835
  */
8029
7836
  function normalizeSlashes(path) {
8030
- var index = path.indexOf("\\");
8031
- if (index === -1) {
8032
- return path;
8033
- }
8034
- backslashRegExp.lastIndex = index; // prime regex with known position
8035
- return path.replace(backslashRegExp, ts.directorySeparator);
7837
+ return path.indexOf("\\") !== -1
7838
+ ? path.replace(backslashRegExp, ts.directorySeparator)
7839
+ : path;
8036
7840
  }
8037
7841
  ts.normalizeSlashes = normalizeSlashes;
8038
7842
  /**
@@ -9733,6 +9537,7 @@ var ts;
9733
9537
  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."),
9734
9538
  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"),
9735
9539
  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"),
9540
+ 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}'"),
9736
9541
  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}'"),
9737
9542
  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."),
9738
9543
  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."),
@@ -19576,21 +19381,17 @@ var ts;
19576
19381
  return getStringFromExpandedCharCodes(expandedCharCodes);
19577
19382
  }
19578
19383
  ts.base64decode = base64decode;
19384
+ function readJsonOrUndefined(path, hostOrText) {
19385
+ var jsonText = ts.isString(hostOrText) ? hostOrText : hostOrText.readFile(path);
19386
+ if (!jsonText)
19387
+ return undefined;
19388
+ // gracefully handle if readFile fails or returns not JSON
19389
+ var result = ts.parseConfigFileTextToJson(path, jsonText);
19390
+ return !result.error ? result.config : undefined;
19391
+ }
19392
+ ts.readJsonOrUndefined = readJsonOrUndefined;
19579
19393
  function readJson(path, host) {
19580
- try {
19581
- var jsonText = host.readFile(path);
19582
- if (!jsonText)
19583
- return {};
19584
- var result = ts.parseConfigFileTextToJson(path, jsonText);
19585
- if (result.error) {
19586
- return {};
19587
- }
19588
- return result.config;
19589
- }
19590
- catch (e) {
19591
- // gracefully handle if readFile fails or returns not JSON
19592
- return {};
19593
- }
19394
+ return readJsonOrUndefined(path, host) || {};
19594
19395
  }
19595
19396
  ts.readJson = readJson;
19596
19397
  function directoryProbablyExists(directoryName, host) {
@@ -27941,9 +27742,10 @@ var ts;
27941
27742
  };
27942
27743
  var buildInfo_1;
27943
27744
  var getAndCacheBuildInfo_1 = function (getText) {
27745
+ var _a;
27944
27746
  if (buildInfo_1 === undefined) {
27945
27747
  var result = getText();
27946
- buildInfo_1 = result !== undefined ? ts.getBuildInfo(result) : false;
27748
+ buildInfo_1 = result !== undefined ? (_a = ts.getBuildInfo(node.buildInfoPath, result)) !== null && _a !== void 0 ? _a : false : false;
27947
27749
  }
27948
27750
  return buildInfo_1 || undefined;
27949
27751
  };
@@ -46003,6 +45805,9 @@ var ts;
46003
45805
  case 203 /* BindingElement */:
46004
45806
  bindBindingElementFlow(node);
46005
45807
  break;
45808
+ case 164 /* Parameter */:
45809
+ bindParameterFlow(node);
45810
+ break;
46006
45811
  case 205 /* ObjectLiteralExpression */:
46007
45812
  case 204 /* ArrayLiteralExpression */:
46008
45813
  case 296 /* PropertyAssignment */:
@@ -46743,20 +46548,38 @@ var ts;
46743
46548
  }
46744
46549
  }
46745
46550
  function bindBindingElementFlow(node) {
46746
- if (ts.isBindingPattern(node.name)) {
46747
- // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46748
- // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46749
- // - `BindingElement: BindingPattern Initializer?`
46750
- // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46751
- // - `BindingElement: BindingPattern Initializer?`
46752
- bind(node.dotDotDotToken);
46753
- bind(node.propertyName);
46754
- bind(node.initializer);
46755
- bind(node.name);
46551
+ // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46552
+ // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46553
+ // - `BindingElement: BindingPattern Initializer?`
46554
+ // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46555
+ // - `BindingElement: BindingPattern Initializer?`
46556
+ bind(node.dotDotDotToken);
46557
+ bind(node.propertyName);
46558
+ bindInitializer(node.initializer);
46559
+ bind(node.name);
46560
+ }
46561
+ function bindParameterFlow(node) {
46562
+ bindEach(node.modifiers);
46563
+ bind(node.dotDotDotToken);
46564
+ bind(node.questionToken);
46565
+ bind(node.type);
46566
+ bindInitializer(node.initializer);
46567
+ bind(node.name);
46568
+ }
46569
+ // a BindingElement/Parameter does not have side effects if initializers are not evaluated and used. (see GH#49759)
46570
+ function bindInitializer(node) {
46571
+ if (!node) {
46572
+ return;
46756
46573
  }
46757
- else {
46758
- bindEachChild(node);
46574
+ var entryFlow = currentFlow;
46575
+ bind(node);
46576
+ if (entryFlow === unreachableFlow || entryFlow === currentFlow) {
46577
+ return;
46759
46578
  }
46579
+ var exitFlow = createBranchLabel();
46580
+ addAntecedent(exitFlow, entryFlow);
46581
+ addAntecedent(exitFlow, currentFlow);
46582
+ currentFlow = finishFlowLabel(exitFlow);
46760
46583
  }
46761
46584
  function bindJSDocTypeAlias(node) {
46762
46585
  bind(node.tagName);
@@ -49927,7 +49750,7 @@ var ts;
49927
49750
  if (unidirectional === void 0) { unidirectional = false; }
49928
49751
  source.forEach(function (sourceSymbol, id) {
49929
49752
  var targetSymbol = target.get(id);
49930
- target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
49753
+ target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : getMergedSymbol(sourceSymbol));
49931
49754
  });
49932
49755
  }
49933
49756
  function mergeModuleAugmentation(moduleName) {
@@ -56718,11 +56541,9 @@ var ts;
56718
56541
  return getReturnTypeOfSignature(getterSignature);
56719
56542
  }
56720
56543
  }
56721
- if (ts.isInJSFile(declaration)) {
56722
- var type_1 = getParameterTypeOfTypeTag(func, declaration);
56723
- if (type_1)
56724
- return type_1;
56725
- }
56544
+ var parameterTypeOfTypeTag = getParameterTypeOfTypeTag(func, declaration);
56545
+ if (parameterTypeOfTypeTag)
56546
+ return parameterTypeOfTypeTag;
56726
56547
  // Use contextual parameter type if one is available
56727
56548
  var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
56728
56549
  if (type) {
@@ -57298,9 +57119,9 @@ var ts;
57298
57119
  if (typeNode === undefined) {
57299
57120
  return useUnknownInCatchVariables ? unknownType : anyType;
57300
57121
  }
57301
- var type_2 = getTypeOfNode(typeNode);
57122
+ var type_1 = getTypeOfNode(typeNode);
57302
57123
  // an errorType will make `checkTryStatement` issue an error
57303
- return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
57124
+ return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
57304
57125
  }
57305
57126
  // Handle export default expressions
57306
57127
  if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
@@ -57510,11 +57331,11 @@ var ts;
57510
57331
  return errorType;
57511
57332
  }
57512
57333
  var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
57513
- var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57334
+ var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57514
57335
  if (!popTypeResolution()) {
57515
57336
  return reportCircularityError(symbol);
57516
57337
  }
57517
- return type_3;
57338
+ return type_2;
57518
57339
  }
57519
57340
  }
57520
57341
  var type = createObjectType(16 /* Anonymous */, symbol);
@@ -59737,10 +59558,10 @@ var ts;
59737
59558
  var baseTypes = [];
59738
59559
  var different = false;
59739
59560
  for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
59740
- var type_4 = types_7[_i];
59741
- var baseType = getBaseConstraint(type_4);
59561
+ var type_3 = types_7[_i];
59562
+ var baseType = getBaseConstraint(type_3);
59742
59563
  if (baseType) {
59743
- if (baseType !== type_4) {
59564
+ if (baseType !== type_3) {
59744
59565
  different = true;
59745
59566
  }
59746
59567
  baseTypes.push(baseType);
@@ -60531,7 +60352,12 @@ var ts;
60531
60352
  continue;
60532
60353
  }
60533
60354
  }
60534
- result.push(getSignatureFromDeclaration(decl));
60355
+ // If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters.
60356
+ // 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.
60357
+ result.push((!ts.isFunctionExpressionOrArrowFunction(decl) &&
60358
+ !ts.isObjectLiteralMethod(decl) &&
60359
+ getSignatureOfTypeTag(decl)) ||
60360
+ getSignatureFromDeclaration(decl));
60535
60361
  }
60536
60362
  return result;
60537
60363
  }
@@ -60562,7 +60388,7 @@ var ts;
60562
60388
  else {
60563
60389
  var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
60564
60390
  var jsdocPredicate = void 0;
60565
- if (!type && ts.isInJSFile(signature.declaration)) {
60391
+ if (!type) {
60566
60392
  var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
60567
60393
  if (jsdocSignature && signature !== jsdocSignature) {
60568
60394
  jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
@@ -64588,15 +64414,14 @@ var ts;
64588
64414
  return false;
64589
64415
  }
64590
64416
  function isContextSensitiveFunctionLikeDeclaration(node) {
64591
- return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
64592
- (ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
64417
+ return ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node);
64593
64418
  }
64594
64419
  function hasContextSensitiveReturnExpression(node) {
64595
64420
  // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value.
64596
64421
  return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body);
64597
64422
  }
64598
64423
  function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
64599
- return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64424
+ return (ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64600
64425
  isContextSensitiveFunctionLikeDeclaration(func);
64601
64426
  }
64602
64427
  function getTypeWithoutSignatures(type) {
@@ -73654,9 +73479,11 @@ var ts;
73654
73479
  case 1 /* ExportsProperty */:
73655
73480
  case 6 /* Prototype */:
73656
73481
  case 3 /* PrototypeProperty */:
73657
- var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
73658
- // falls through
73659
73482
  case 2 /* ModuleExports */:
73483
+ var valueDeclaration = void 0;
73484
+ if (kind !== 2 /* ModuleExports */) {
73485
+ valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
73486
+ }
73660
73487
  valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration);
73661
73488
  var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration);
73662
73489
  return annotated ? getTypeFromTypeNode(annotated) : undefined;
@@ -74134,9 +73961,18 @@ var ts;
74134
73961
  if (!isErrorType(intrinsicClassAttribs)) {
74135
73962
  var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
74136
73963
  var hostClassType = getReturnTypeOfSignature(sig);
74137
- apparentAttributesType = intersectTypes(typeParams
74138
- ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
74139
- : intrinsicClassAttribs, apparentAttributesType);
73964
+ var libraryManagedAttributeType = void 0;
73965
+ if (typeParams && typeParams.length === 1) {
73966
+ var inferredArgs = fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context));
73967
+ libraryManagedAttributeType = instantiateType(intrinsicClassAttribs, createTypeMapper(typeParams, inferredArgs));
73968
+ }
73969
+ else if (typeParams)
73970
+ libraryManagedAttributeType = undefined;
73971
+ else
73972
+ libraryManagedAttributeType = intrinsicClassAttribs;
73973
+ if (libraryManagedAttributeType) {
73974
+ apparentAttributesType = intersectTypes(libraryManagedAttributeType, apparentAttributesType);
73975
+ }
74140
73976
  }
74141
73977
  var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
74142
73978
  if (!isErrorType(intrinsicAttribs)) {
@@ -74641,16 +74477,30 @@ var ts;
74641
74477
  // If object literal is contextually typed by the implied type of a binding pattern, augment the result
74642
74478
  // type with those properties for which the binding pattern specifies a default value.
74643
74479
  // If the object literal is spread into another object literal, skip this step and let the top-level object
74644
- // literal handle it instead.
74645
- if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) {
74646
- for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74647
- var prop = _e[_d];
74648
- if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74649
- if (!(prop.flags & 16777216 /* Optional */)) {
74650
- error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74480
+ // literal handle it instead. Note that this might require full traversal to the root pattern's parent
74481
+ // as it's the guaranteed to be the common ancestor of the pattern node and the current object node.
74482
+ // It's not possible to check if the immediate parent node is a spread assignment
74483
+ // since the type flows in non-obvious ways through conditional expressions, IIFEs and more.
74484
+ if (contextualTypeHasPattern) {
74485
+ var rootPatternParent_1 = ts.findAncestor(contextualType.pattern.parent, function (n) {
74486
+ return n.kind === 254 /* VariableDeclaration */ ||
74487
+ n.kind === 221 /* BinaryExpression */ ||
74488
+ n.kind === 164 /* Parameter */;
74489
+ });
74490
+ var spreadOrOutsideRootObject = ts.findAncestor(node, function (n) {
74491
+ return n === rootPatternParent_1 ||
74492
+ n.kind === 298 /* SpreadAssignment */;
74493
+ });
74494
+ if (spreadOrOutsideRootObject.kind !== 298 /* SpreadAssignment */) {
74495
+ for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74496
+ var prop = _e[_d];
74497
+ if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74498
+ if (!(prop.flags & 16777216 /* Optional */)) {
74499
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74500
+ }
74501
+ propertiesTable.set(prop.escapedName, prop);
74502
+ propertiesArray.push(prop);
74651
74503
  }
74652
- propertiesTable.set(prop.escapedName, prop);
74653
- propertiesArray.push(prop);
74654
74504
  }
74655
74505
  }
74656
74506
  }
@@ -77949,12 +77799,15 @@ var ts;
77949
77799
  return false;
77950
77800
  }
77951
77801
  var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
77952
- ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
77802
+ (ts.isVariableDeclaration(node) || ts.isPropertyAssignment(node)) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
77953
77803
  undefined;
77954
77804
  if (func) {
77955
- // If the node has a @class tag, treat it like a constructor.
77805
+ // If the node has a @class or @constructor tag, treat it like a constructor.
77956
77806
  if (ts.getJSDocClassTag(node))
77957
77807
  return true;
77808
+ // If the node is a property of an object literal.
77809
+ if (ts.isPropertyAssignment(ts.walkUpParenthesizedExpressions(func.parent)))
77810
+ return false;
77958
77811
  // If the symbol of the node has members, treat it like a constructor.
77959
77812
  var symbol = getSymbolOfNode(func);
77960
77813
  return !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.members) === null || _a === void 0 ? void 0 : _a.size);
@@ -78202,8 +78055,8 @@ var ts;
78202
78055
  if (hasDefaultOnly && type && !isErrorType(type)) {
78203
78056
  var synthType = type;
78204
78057
  if (!synthType.defaultOnlyType) {
78205
- var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78206
- synthType.defaultOnlyType = type_5;
78058
+ var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78059
+ synthType.defaultOnlyType = type_4;
78207
78060
  }
78208
78061
  return synthType.defaultOnlyType;
78209
78062
  }
@@ -87540,6 +87393,12 @@ var ts;
87540
87393
  return resolveJSDocMemberName(name, /*ignoreErrors*/ false, getSymbolOfNode(container));
87541
87394
  }
87542
87395
  }
87396
+ if (result && isJSDoc_1) {
87397
+ var container = ts.getJSDocHost(name);
87398
+ if (container && ts.isEnumMember(container) && container === result.valueDeclaration) {
87399
+ return resolveEntityName(name, meaning, /*ignoreErrors*/ true, /* dontResolveAlias */ true, ts.getSourceFileOfNode(container)) || result;
87400
+ }
87401
+ }
87543
87402
  return result;
87544
87403
  }
87545
87404
  else if (ts.isPrivateIdentifier(name)) {
@@ -107701,6 +107560,13 @@ var ts;
107701
107560
  ts.Debug.assert(importVariableName !== undefined);
107702
107561
  // save import into the local
107703
107562
  statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
107563
+ if (ts.hasSyntacticModifier(entry, 1 /* Export */)) {
107564
+ statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction,
107565
+ /*typeArguments*/ undefined, [
107566
+ factory.createStringLiteral(ts.idText(importVariableName)),
107567
+ parameterName,
107568
+ ])));
107569
+ }
107704
107570
  break;
107705
107571
  case 272 /* ExportDeclaration */:
107706
107572
  ts.Debug.assert(importVariableName !== undefined);
@@ -110543,8 +110409,12 @@ var ts;
110543
110409
  }
110544
110410
  var previousNeedsDeclare = needsDeclare;
110545
110411
  switch (input.kind) {
110546
- case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all
110547
- return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110412
+ case 259 /* TypeAliasDeclaration */: {
110413
+ needsDeclare = false;
110414
+ var clean = cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110415
+ needsDeclare = previousNeedsDeclare;
110416
+ return clean;
110417
+ }
110548
110418
  case 258 /* InterfaceDeclaration */: {
110549
110419
  return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
110550
110420
  }
@@ -112048,8 +111918,8 @@ var ts;
112048
111918
  }
112049
111919
  ts.getBuildInfoText = getBuildInfoText;
112050
111920
  /*@internal*/
112051
- function getBuildInfo(buildInfoText) {
112052
- return JSON.parse(buildInfoText);
111921
+ function getBuildInfo(buildInfoFile, buildInfoText) {
111922
+ return ts.readJsonOrUndefined(buildInfoFile, buildInfoText);
112053
111923
  }
112054
111924
  ts.getBuildInfo = getBuildInfo;
112055
111925
  /*@internal*/
@@ -112127,17 +111997,16 @@ var ts;
112127
111997
  var buildInfo;
112128
111998
  if (host.getBuildInfo) {
112129
111999
  // If host directly provides buildinfo we can get it directly. This allows host to cache the buildinfo
112130
- var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
112131
- if (!hostBuildInfo)
112132
- return buildInfoPath;
112133
- buildInfo = hostBuildInfo;
112000
+ buildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
112134
112001
  }
112135
112002
  else {
112136
112003
  var buildInfoText = host.readFile(buildInfoPath);
112137
112004
  if (!buildInfoText)
112138
112005
  return buildInfoPath;
112139
- buildInfo = getBuildInfo(buildInfoText);
112006
+ buildInfo = getBuildInfo(buildInfoPath, buildInfoText);
112140
112007
  }
112008
+ if (!buildInfo)
112009
+ return buildInfoPath;
112141
112010
  if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
112142
112011
  return buildInfoPath;
112143
112012
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
@@ -116795,7 +116664,16 @@ var ts;
116795
116664
  return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
116796
116665
  }
116797
116666
  function getCachedFileSystemEntriesForBaseDir(path) {
116798
- return getCachedFileSystemEntries(ts.getDirectoryPath(path));
116667
+ var entries = getCachedFileSystemEntries(ts.getDirectoryPath(path));
116668
+ if (!entries) {
116669
+ return entries;
116670
+ }
116671
+ // If we're looking for the base directory, we're definitely going to search the entries
116672
+ if (!entries.sortedAndCanonicalizedFiles) {
116673
+ entries.sortedAndCanonicalizedFiles = entries.files.map(getCanonicalFileName).sort();
116674
+ entries.sortedAndCanonicalizedDirectories = entries.directories.map(getCanonicalFileName).sort();
116675
+ }
116676
+ return entries;
116799
116677
  }
116800
116678
  function getBaseNameOfFileName(fileName) {
116801
116679
  return ts.getBaseFileName(ts.normalizePath(fileName));
@@ -116838,21 +116716,10 @@ var ts;
116838
116716
  return undefined;
116839
116717
  }
116840
116718
  }
116841
- function fileNameEqual(name1, name2) {
116842
- return getCanonicalFileName(name1) === getCanonicalFileName(name2);
116843
- }
116844
116719
  function hasEntry(entries, name) {
116845
- return ts.some(entries, function (file) { return fileNameEqual(file, name); });
116846
- }
116847
- function updateFileSystemEntry(entries, baseName, isValid) {
116848
- if (hasEntry(entries, baseName)) {
116849
- if (!isValid) {
116850
- return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
116851
- }
116852
- }
116853
- else if (isValid) {
116854
- return entries.push(baseName);
116855
- }
116720
+ // Case-sensitive comparison since already canonicalized
116721
+ var index = ts.binarySearch(entries, name, ts.identity, ts.compareStringsCaseSensitive);
116722
+ return index >= 0;
116856
116723
  }
116857
116724
  function writeFile(fileName, data, writeByteOrderMark) {
116858
116725
  var path = toPath(fileName);
@@ -116865,7 +116732,7 @@ var ts;
116865
116732
  function fileExists(fileName) {
116866
116733
  var path = toPath(fileName);
116867
116734
  var result = getCachedFileSystemEntriesForBaseDir(path);
116868
- return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
116735
+ return result && hasEntry(result.sortedAndCanonicalizedFiles, getCanonicalFileName(getBaseNameOfFileName(fileName))) ||
116869
116736
  host.fileExists(fileName);
116870
116737
  }
116871
116738
  function directoryExists(dirPath) {
@@ -116875,9 +116742,14 @@ var ts;
116875
116742
  function createDirectory(dirPath) {
116876
116743
  var path = toPath(dirPath);
116877
116744
  var result = getCachedFileSystemEntriesForBaseDir(path);
116878
- var baseFileName = getBaseNameOfFileName(dirPath);
116879
116745
  if (result) {
116880
- updateFileSystemEntry(result.directories, baseFileName, /*isValid*/ true);
116746
+ var baseName = getBaseNameOfFileName(dirPath);
116747
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
116748
+ var canonicalizedDirectories = result.sortedAndCanonicalizedDirectories;
116749
+ // Case-sensitive comparison since already canonicalized
116750
+ if (ts.insertSorted(canonicalizedDirectories, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
116751
+ result.directories.push(baseName);
116752
+ }
116881
116753
  }
116882
116754
  host.createDirectory(dirPath);
116883
116755
  }
@@ -116946,7 +116818,7 @@ var ts;
116946
116818
  fileExists: host.fileExists(fileOrDirectoryPath),
116947
116819
  directoryExists: host.directoryExists(fileOrDirectoryPath)
116948
116820
  };
116949
- if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
116821
+ if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
116950
116822
  // Folder added or removed, clear the cache instead of updating the folder and its structure
116951
116823
  clearCache();
116952
116824
  }
@@ -116966,7 +116838,23 @@ var ts;
116966
116838
  }
116967
116839
  }
116968
116840
  function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
116969
- updateFileSystemEntry(parentResult.files, baseName, fileExists);
116841
+ var canonicalizedFiles = parentResult.sortedAndCanonicalizedFiles;
116842
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
116843
+ if (fileExists) {
116844
+ // Case-sensitive comparison since already canonicalized
116845
+ if (ts.insertSorted(canonicalizedFiles, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
116846
+ parentResult.files.push(baseName);
116847
+ }
116848
+ }
116849
+ else {
116850
+ // Case-sensitive comparison since already canonicalized
116851
+ var sortedIndex = ts.binarySearch(canonicalizedFiles, canonicalizedBaseName, ts.identity, ts.compareStringsCaseSensitive);
116852
+ if (sortedIndex >= 0) {
116853
+ canonicalizedFiles.splice(sortedIndex, 1);
116854
+ var unsortedIndex = parentResult.files.findIndex(function (entry) { return getCanonicalFileName(entry) === canonicalizedBaseName; });
116855
+ parentResult.files.splice(unsortedIndex, 1);
116856
+ }
116857
+ }
116970
116858
  }
116971
116859
  function clearCache() {
116972
116860
  cachedReadDirectoryResult.clear();
@@ -125204,18 +125092,14 @@ var ts;
125204
125092
  if (host.getBuildInfo) {
125205
125093
  // host provides buildinfo, get it from there. This allows host to cache it
125206
125094
  buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
125207
- if (!buildInfo)
125208
- return undefined;
125209
125095
  }
125210
125096
  else {
125211
125097
  var content = host.readFile(buildInfoPath);
125212
125098
  if (!content)
125213
125099
  return undefined;
125214
- buildInfo = ts.getBuildInfo(content);
125100
+ buildInfo = ts.getBuildInfo(buildInfoPath, content);
125215
125101
  }
125216
- if (buildInfo.version !== ts.version)
125217
- return undefined;
125218
- if (!buildInfo.program)
125102
+ if (!buildInfo || buildInfo.version !== ts.version || !buildInfo.program)
125219
125103
  return undefined;
125220
125104
  return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
125221
125105
  }
@@ -125437,7 +125321,8 @@ var ts;
125437
125321
  }
125438
125322
  // All resolutions are invalid if user provided resolutions
125439
125323
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
125440
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
125324
+ var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
125325
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
125441
125326
  if (hasChangedConfigFileParsingErrors) {
125442
125327
  if (reportFileChangeDetectedOnCreateProgram) {
125443
125328
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -125456,6 +125341,11 @@ var ts;
125456
125341
  if (host.afterProgramCreate && program !== builderProgram) {
125457
125342
  host.afterProgramCreate(builderProgram);
125458
125343
  }
125344
+ compilerHost.readFile = originalReadFile;
125345
+ compilerHost.fileExists = originalFileExists;
125346
+ compilerHost.directoryExists = originalDirectoryExists;
125347
+ compilerHost.createDirectory = originalCreateDirectory;
125348
+ compilerHost.writeFile = originalWriteFile;
125459
125349
  return builderProgram;
125460
125350
  }
125461
125351
  function createNewProgram(hasInvalidatedResolution) {
@@ -125933,19 +125823,20 @@ var ts;
125933
125823
  */
125934
125824
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
125935
125825
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
125936
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
125937
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
125938
- UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
125939
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
125940
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
125941
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
125942
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
125943
- UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
125826
+ UpToDateStatusType[UpToDateStatusType["ErrorReadingFile"] = 5] = "ErrorReadingFile";
125827
+ UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 6] = "OutOfDateWithSelf";
125828
+ UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 7] = "OutOfDateWithUpstream";
125829
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 8] = "OutOfDateBuildInfo";
125830
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 9] = "UpstreamOutOfDate";
125831
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 10] = "UpstreamBlocked";
125832
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 11] = "ComputingUpstream";
125833
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 12] = "TsVersionOutputOfDate";
125834
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 13] = "UpToDateWithInputFileText";
125944
125835
  /**
125945
125836
  * Projects with no outputs (i.e. "solution" files)
125946
125837
  */
125947
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
125948
- UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
125838
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 14] = "ContainerOnly";
125839
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 15] = "ForceBuild";
125949
125840
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
125950
125841
  function resolveConfigFileProjectName(project) {
125951
125842
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -126647,13 +126538,13 @@ var ts;
126647
126538
  var emitterDiagnostics = ts.createDiagnosticCollection();
126648
126539
  var emittedOutputs = new ts.Map();
126649
126540
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
126650
- var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
126541
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo || undefined;
126651
126542
  outputFiles.forEach(function (_a) {
126652
126543
  var _b, _c;
126653
126544
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
126654
126545
  emittedOutputs.set(toPath(state, name), name);
126655
126546
  if (buildInfo) {
126656
- if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) {
126547
+ 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)) {
126657
126548
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
126658
126549
  }
126659
126550
  setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags);
@@ -126946,8 +126837,7 @@ var ts;
126946
126837
  return existing.buildInfo || undefined;
126947
126838
  }
126948
126839
  var value = state.readFileWithCache(buildInfoPath);
126949
- var buildInfo = value ? ts.getBuildInfo(value) : undefined;
126950
- ts.Debug.assert(modifiedTime || !buildInfo);
126840
+ var buildInfo = value ? ts.getBuildInfo(buildInfoPath, value) : undefined;
126951
126841
  state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
126952
126842
  return buildInfo;
126953
126843
  }
@@ -127032,7 +126922,14 @@ var ts;
127032
126922
  missingOutputFileName: buildInfoPath
127033
126923
  };
127034
126924
  }
127035
- var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
126925
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime);
126926
+ if (!buildInfo) {
126927
+ // Error reading buildInfo
126928
+ return {
126929
+ type: ts.UpToDateStatusType.ErrorReadingFile,
126930
+ fileName: buildInfoPath
126931
+ };
126932
+ }
127036
126933
  if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
127037
126934
  return {
127038
126935
  type: ts.UpToDateStatusType.TsVersionOutputOfDate,
@@ -127690,6 +127587,8 @@ var ts;
127690
127587
  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));
127691
127588
  case ts.UpToDateStatusType.OutputMissing:
127692
127589
  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));
127590
+ case ts.UpToDateStatusType.ErrorReadingFile:
127591
+ 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));
127693
127592
  case ts.UpToDateStatusType.OutOfDateBuildInfo:
127694
127593
  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));
127695
127594
  case ts.UpToDateStatusType.UpToDate:
@@ -157143,6 +157042,15 @@ var ts;
157143
157042
  ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code,
157144
157043
  ts.Diagnostics.Cannot_find_name_0.code
157145
157044
  ];
157045
+ var InfoKind;
157046
+ (function (InfoKind) {
157047
+ InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
157048
+ InfoKind[InfoKind["Enum"] = 1] = "Enum";
157049
+ InfoKind[InfoKind["Function"] = 2] = "Function";
157050
+ InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
157051
+ InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
157052
+ InfoKind[InfoKind["Signature"] = 5] = "Signature";
157053
+ })(InfoKind || (InfoKind = {}));
157146
157054
  codefix.registerCodeFix({
157147
157055
  errorCodes: errorCodes,
157148
157056
  getCodeActions: function (context) {
@@ -157151,19 +157059,19 @@ var ts;
157151
157059
  if (!info) {
157152
157060
  return undefined;
157153
157061
  }
157154
- if (info.kind === 3 /* ObjectLiteral */) {
157062
+ if (info.kind === InfoKind.ObjectLiteral) {
157155
157063
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); });
157156
157064
  return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)];
157157
157065
  }
157158
- if (info.kind === 4 /* JsxAttributes */) {
157066
+ if (info.kind === InfoKind.JsxAttributes) {
157159
157067
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); });
157160
157068
  return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)];
157161
157069
  }
157162
- if (info.kind === 2 /* Function */) {
157070
+ if (info.kind === InfoKind.Function || info.kind === InfoKind.Signature) {
157163
157071
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); });
157164
157072
  return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)];
157165
157073
  }
157166
- if (info.kind === 1 /* Enum */) {
157074
+ if (info.kind === InfoKind.Enum) {
157167
157075
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); });
157168
157076
  return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
157169
157077
  }
@@ -157181,20 +157089,20 @@ var ts;
157181
157089
  if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) {
157182
157090
  return;
157183
157091
  }
157184
- if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) {
157092
+ if (fixId === fixMissingFunctionDeclaration && (info.kind === InfoKind.Function || info.kind === InfoKind.Signature)) {
157185
157093
  addFunctionDeclaration(changes, context, info);
157186
157094
  }
157187
- else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
157095
+ else if (fixId === fixMissingProperties && info.kind === InfoKind.ObjectLiteral) {
157188
157096
  addObjectLiteralProperties(changes, context, info);
157189
157097
  }
157190
- else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
157098
+ else if (fixId === fixMissingAttributes && info.kind === InfoKind.JsxAttributes) {
157191
157099
  addJsxAttributes(changes, context, info);
157192
157100
  }
157193
157101
  else {
157194
- if (info.kind === 1 /* Enum */) {
157102
+ if (info.kind === InfoKind.Enum) {
157195
157103
  addEnumMemberDeclaration(changes, checker, info);
157196
157104
  }
157197
- if (info.kind === 0 /* TypeLikeDeclaration */) {
157105
+ if (info.kind === InfoKind.TypeLikeDeclaration) {
157198
157106
  var parentDeclaration = info.parentDeclaration, token_1 = info.token;
157199
157107
  var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; });
157200
157108
  if (!infos.some(function (i) { return i.token.text === token_1.text; })) {
@@ -157238,14 +157146,6 @@ var ts;
157238
157146
  }));
157239
157147
  },
157240
157148
  });
157241
- var InfoKind;
157242
- (function (InfoKind) {
157243
- InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
157244
- InfoKind[InfoKind["Enum"] = 1] = "Enum";
157245
- InfoKind[InfoKind["Function"] = 2] = "Function";
157246
- InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
157247
- InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
157248
- })(InfoKind || (InfoKind = {}));
157249
157149
  function getInfo(sourceFile, tokenPos, errorCode, checker, program) {
157250
157150
  // The identifier of the missing property. eg:
157251
157151
  // this.missing = 1;
@@ -157267,7 +157167,7 @@ var ts;
157267
157167
  var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
157268
157168
  if (!ts.length(properties))
157269
157169
  return undefined;
157270
- return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent };
157170
+ return { kind: InfoKind.ObjectLiteral, token: param.name, properties: properties, parentDeclaration: parent };
157271
157171
  }
157272
157172
  if (!ts.isMemberName(token))
157273
157173
  return undefined;
@@ -157275,17 +157175,26 @@ var ts;
157275
157175
  var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
157276
157176
  if (!ts.length(properties))
157277
157177
  return undefined;
157278
- return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer };
157178
+ return { kind: InfoKind.ObjectLiteral, token: token, properties: properties, parentDeclaration: parent.initializer };
157279
157179
  }
157280
157180
  if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) {
157281
157181
  var target = ts.getEmitScriptTarget(program.getCompilerOptions());
157282
157182
  var attributes = getUnmatchedAttributes(checker, target, token.parent);
157283
157183
  if (!ts.length(attributes))
157284
157184
  return undefined;
157285
- return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
157185
+ return { kind: InfoKind.JsxAttributes, token: token, attributes: attributes, parentDeclaration: token.parent };
157286
157186
  }
157287
- if (ts.isIdentifier(token) && ts.isCallExpression(parent) && parent.expression === token) {
157288
- return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile };
157187
+ if (ts.isIdentifier(token)) {
157188
+ var type = checker.getContextualType(token);
157189
+ if (type && ts.getObjectFlags(type) & 16 /* Anonymous */) {
157190
+ var signature = ts.firstOrUndefined(checker.getSignaturesOfType(type, 0 /* Call */));
157191
+ if (signature === undefined)
157192
+ return undefined;
157193
+ return { kind: InfoKind.Signature, token: token, signature: signature, sourceFile: sourceFile, parentDeclaration: findScope(token) };
157194
+ }
157195
+ if (ts.isCallExpression(parent) && parent.expression === token) {
157196
+ return { kind: InfoKind.Function, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: findScope(token) };
157197
+ }
157289
157198
  }
157290
157199
  if (!ts.isPropertyAccessExpression(parent))
157291
157200
  return undefined;
@@ -157297,13 +157206,13 @@ var ts;
157297
157206
  var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
157298
157207
  var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
157299
157208
  if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
157300
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration };
157209
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration };
157301
157210
  }
157302
157211
  var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
157303
157212
  if (sourceFile.commonJsModuleIndicator)
157304
157213
  return undefined;
157305
157214
  if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
157306
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile };
157215
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile };
157307
157216
  }
157308
157217
  }
157309
157218
  var classDeclaration = ts.find(symbol.declarations, ts.isClassLike);
@@ -157321,11 +157230,11 @@ var ts;
157321
157230
  (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */);
157322
157231
  var isJSFile = ts.isSourceFileJS(declSourceFile);
157323
157232
  var call = ts.tryCast(parent.parent, ts.isCallExpression);
157324
- return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
157233
+ return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
157325
157234
  }
157326
157235
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
157327
157236
  if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
157328
- return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration };
157237
+ return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
157329
157238
  }
157330
157239
  return undefined;
157331
157240
  }
@@ -157501,9 +157410,17 @@ var ts;
157501
157410
  });
157502
157411
  }
157503
157412
  function addFunctionDeclaration(changes, context, info) {
157413
+ var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
157504
157414
  var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
157505
- var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration);
157506
- changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
157415
+ var functionDeclaration = info.kind === InfoKind.Function
157416
+ ? codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration)
157417
+ : codefix.createSignatureDeclarationFromSignature(256 /* FunctionDeclaration */, context, quotePreference, info.signature, codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), info.token, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ undefined, importAdder);
157418
+ if (functionDeclaration === undefined) {
157419
+ ts.Debug.fail("fixMissingFunctionDeclaration codefix got unexpected error.");
157420
+ }
157421
+ ts.isReturnStatement(info.parentDeclaration)
157422
+ ? changes.insertNodeBefore(info.sourceFile, info.parentDeclaration, functionDeclaration, /*blankLineBetween*/ true)
157423
+ : changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
157507
157424
  importAdder.writeFixes(changes);
157508
157425
  }
157509
157426
  function addJsxAttributes(changes, context, info) {
@@ -157661,6 +157578,14 @@ var ts;
157661
157578
  }
157662
157579
  return ts.createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === 0 /* Single */);
157663
157580
  }
157581
+ function findScope(node) {
157582
+ if (ts.findAncestor(node, ts.isJsxExpression)) {
157583
+ var returnStatement = ts.findAncestor(node.parent, ts.isReturnStatement);
157584
+ if (returnStatement)
157585
+ return returnStatement;
157586
+ }
157587
+ return ts.getSourceFileOfNode(node);
157588
+ }
157664
157589
  })(codefix = ts.codefix || (ts.codefix = {}));
157665
157590
  })(ts || (ts = {}));
157666
157591
  /* @internal */
@@ -160350,6 +160275,9 @@ var ts;
160350
160275
  if (ts.isMethodDeclaration(signatureDeclaration)) {
160351
160276
  return ts.factory.updateMethodDeclaration(signatureDeclaration, modifiers, asteriskToken, name !== null && name !== void 0 ? name : ts.factory.createIdentifier(""), questionToken, typeParameters, parameters, type, body);
160352
160277
  }
160278
+ if (ts.isFunctionDeclaration(signatureDeclaration)) {
160279
+ return ts.factory.updateFunctionDeclaration(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body);
160280
+ }
160353
160281
  return undefined;
160354
160282
  }
160355
160283
  codefix.createSignatureDeclarationFromSignature = createSignatureDeclarationFromSignature;
@@ -167652,6 +167580,10 @@ var ts;
167652
167580
  getCurrentDirectory: compilerHost.getCurrentDirectory,
167653
167581
  onUnRecoverableConfigFileDiagnostic: ts.noop,
167654
167582
  };
167583
+ // The call to isProgramUptoDate below may refer back to documentRegistryBucketKey;
167584
+ // calculate this early so it's not undefined if downleveled to a var (or, if emitted
167585
+ // as a const variable without downleveling, doesn't crash).
167586
+ var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
167655
167587
  // If the program is already up-to-date, we can reuse it
167656
167588
  if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
167657
167589
  return;
@@ -167661,7 +167593,6 @@ var ts;
167661
167593
  // instance. If we cancel midway through, we may end up in an inconsistent state where
167662
167594
  // the program points to old source files that have been invalidated because of
167663
167595
  // incremental parsing.
167664
- var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
167665
167596
  var options = {
167666
167597
  rootNames: rootFileNames,
167667
167598
  options: newSettings,