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.
@@ -100,210 +100,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
100
100
  step((generator = generator.apply(thisArg, _arguments || [])).next());
101
101
  });
102
102
  };
103
- /* @internal */
104
- var ts;
105
- (function (ts) {
106
- function createMapData() {
107
- var sentinel = {};
108
- sentinel.prev = sentinel;
109
- return { head: sentinel, tail: sentinel, size: 0 };
110
- }
111
- function createMapEntry(key, value) {
112
- return { key: key, value: value, next: undefined, prev: undefined };
113
- }
114
- function sameValueZero(x, y) {
115
- // Treats -0 === 0 and NaN === NaN
116
- return x === y || x !== x && y !== y;
117
- }
118
- function getPrev(entry) {
119
- var prev = entry.prev;
120
- // Entries without a 'prev' have been removed from the map.
121
- // An entry whose 'prev' points to itself is the head of the list and is invalid here.
122
- if (!prev || prev === entry)
123
- throw new Error("Illegal state");
124
- return prev;
125
- }
126
- function getNext(entry) {
127
- while (entry) {
128
- // Entries without a 'prev' have been removed from the map. Their 'next'
129
- // pointer should point to the previous entry prior to deletion and
130
- // that entry should be skipped to resume iteration.
131
- var skipNext = !entry.prev;
132
- entry = entry.next;
133
- if (skipNext) {
134
- continue;
135
- }
136
- return entry;
137
- }
138
- }
139
- function getEntry(data, key) {
140
- // We walk backwards from 'tail' to prioritize recently added entries.
141
- // We skip 'head' because it is an empty entry used to track iteration start.
142
- for (var entry = data.tail; entry !== data.head; entry = getPrev(entry)) {
143
- if (sameValueZero(entry.key, key)) {
144
- return entry;
145
- }
146
- }
147
- }
148
- function addOrUpdateEntry(data, key, value) {
149
- var existing = getEntry(data, key);
150
- if (existing) {
151
- existing.value = value;
152
- return;
153
- }
154
- var entry = createMapEntry(key, value);
155
- entry.prev = data.tail;
156
- data.tail.next = entry;
157
- data.tail = entry;
158
- data.size++;
159
- return entry;
160
- }
161
- function deleteEntry(data, key) {
162
- // We walk backwards from 'tail' to prioritize recently added entries.
163
- // We skip 'head' because it is an empty entry used to track iteration start.
164
- for (var entry = data.tail; entry !== data.head; entry = getPrev(entry)) {
165
- // all entries in the map should have a 'prev' pointer.
166
- if (entry.prev === undefined)
167
- throw new Error("Illegal state");
168
- if (sameValueZero(entry.key, key)) {
169
- if (entry.next) {
170
- entry.next.prev = entry.prev;
171
- }
172
- else {
173
- // an entry in the map without a 'next' pointer must be the 'tail'.
174
- if (data.tail !== entry)
175
- throw new Error("Illegal state");
176
- data.tail = entry.prev;
177
- }
178
- entry.prev.next = entry.next;
179
- entry.next = entry.prev;
180
- entry.prev = undefined;
181
- data.size--;
182
- return entry;
183
- }
184
- }
185
- }
186
- function clearEntries(data) {
187
- var node = data.tail;
188
- while (node !== data.head) {
189
- var prev = getPrev(node);
190
- node.next = data.head;
191
- node.prev = undefined;
192
- node = prev;
193
- }
194
- data.head.next = undefined;
195
- data.tail = data.head;
196
- data.size = 0;
197
- }
198
- function forEachEntry(data, action) {
199
- var entry = data.head;
200
- while (entry) {
201
- entry = getNext(entry);
202
- if (entry) {
203
- action(entry.value, entry.key);
204
- }
205
- }
206
- }
207
- function forEachIteration(iterator, action) {
208
- if (iterator) {
209
- for (var step = iterator.next(); !step.done; step = iterator.next()) {
210
- action(step.value);
211
- }
212
- }
213
- }
214
- function createIteratorData(data, selector) {
215
- return { current: data.head, selector: selector };
216
- }
217
- function iteratorNext(data) {
218
- // Navigate to the next entry.
219
- data.current = getNext(data.current);
220
- if (data.current) {
221
- return { value: data.selector(data.current.key, data.current.value), done: false };
222
- }
223
- else {
224
- return { value: undefined, done: true };
225
- }
226
- }
227
- /* @internal */
228
- var ShimCollections;
229
- (function (ShimCollections) {
230
- function createMapShim(getIterator) {
231
- var MapIterator = /** @class */ (function () {
232
- function MapIterator(data, selector) {
233
- this._data = createIteratorData(data, selector);
234
- }
235
- MapIterator.prototype.next = function () { return iteratorNext(this._data); };
236
- return MapIterator;
237
- }());
238
- return /** @class */ (function () {
239
- function Map(iterable) {
240
- var _this = this;
241
- this._mapData = createMapData();
242
- forEachIteration(getIterator(iterable), function (_a) {
243
- var key = _a[0], value = _a[1];
244
- return _this.set(key, value);
245
- });
246
- }
247
- Object.defineProperty(Map.prototype, "size", {
248
- get: function () { return this._mapData.size; },
249
- enumerable: false,
250
- configurable: true
251
- });
252
- Map.prototype.get = function (key) { var _a; return (_a = getEntry(this._mapData, key)) === null || _a === void 0 ? void 0 : _a.value; };
253
- Map.prototype.set = function (key, value) { return addOrUpdateEntry(this._mapData, key, value), this; };
254
- Map.prototype.has = function (key) { return !!getEntry(this._mapData, key); };
255
- Map.prototype.delete = function (key) { return !!deleteEntry(this._mapData, key); };
256
- Map.prototype.clear = function () { clearEntries(this._mapData); };
257
- Map.prototype.keys = function () { return new MapIterator(this._mapData, function (key, _value) { return key; }); };
258
- Map.prototype.values = function () { return new MapIterator(this._mapData, function (_key, value) { return value; }); };
259
- Map.prototype.entries = function () { return new MapIterator(this._mapData, function (key, value) { return [key, value]; }); };
260
- Map.prototype.forEach = function (action) { forEachEntry(this._mapData, action); };
261
- return Map;
262
- }());
263
- }
264
- ShimCollections.createMapShim = createMapShim;
265
- function createSetShim(getIterator) {
266
- var SetIterator = /** @class */ (function () {
267
- function SetIterator(data, selector) {
268
- this._data = createIteratorData(data, selector);
269
- }
270
- SetIterator.prototype.next = function () { return iteratorNext(this._data); };
271
- return SetIterator;
272
- }());
273
- return /** @class */ (function () {
274
- function Set(iterable) {
275
- var _this = this;
276
- this._mapData = createMapData();
277
- forEachIteration(getIterator(iterable), function (value) { return _this.add(value); });
278
- }
279
- Object.defineProperty(Set.prototype, "size", {
280
- get: function () { return this._mapData.size; },
281
- enumerable: false,
282
- configurable: true
283
- });
284
- Set.prototype.add = function (value) { return addOrUpdateEntry(this._mapData, value, value), this; };
285
- Set.prototype.has = function (value) { return !!getEntry(this._mapData, value); };
286
- Set.prototype.delete = function (value) { return !!deleteEntry(this._mapData, value); };
287
- Set.prototype.clear = function () { clearEntries(this._mapData); };
288
- Set.prototype.keys = function () { return new SetIterator(this._mapData, function (key, _value) { return key; }); };
289
- Set.prototype.values = function () { return new SetIterator(this._mapData, function (_key, value) { return value; }); };
290
- Set.prototype.entries = function () { return new SetIterator(this._mapData, function (key, value) { return [key, value]; }); };
291
- Set.prototype.forEach = function (action) { forEachEntry(this._mapData, action); };
292
- return Set;
293
- }());
294
- }
295
- ShimCollections.createSetShim = createSetShim;
296
- })(ShimCollections = ts.ShimCollections || (ts.ShimCollections = {}));
297
- })(ts || (ts = {}));
298
103
  var ts;
299
104
  (function (ts) {
300
105
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
301
106
  // If changing the text in this section, be sure to test `configurePrerelease` too.
302
- ts.versionMajorMinor = "4.8";
107
+ ts.versionMajorMinor = "4.9";
303
108
  // The following is baselined as a literal template type without intervention
304
109
  /** The version of the TypeScript compiler release */
305
110
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
306
- ts.version = ts.versionMajorMinor + ".0-dev.20220807";
111
+ ts.version = ts.versionMajorMinor + ".0-dev.20220811";
307
112
  /* @internal */
308
113
  var Comparison;
309
114
  (function (Comparison) {
@@ -325,7 +130,11 @@ var ts;
325
130
  // Internet Explorer's Map doesn't support iteration, so don't use it.
326
131
  var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
327
132
  // eslint-disable-next-line no-in-operator
328
- return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
133
+ var constructor = typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
134
+ if (!constructor) {
135
+ throw new Error("No compatible Map implementation found.");
136
+ }
137
+ return constructor;
329
138
  }
330
139
  NativeCollections.tryGetNativeMap = tryGetNativeMap;
331
140
  /**
@@ -335,23 +144,18 @@ var ts;
335
144
  // Internet Explorer's Set doesn't support iteration, so don't use it.
336
145
  var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
337
146
  // eslint-disable-next-line no-in-operator
338
- return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
147
+ var constructor = typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
148
+ if (!constructor) {
149
+ throw new Error("No compatible Set implementation found.");
150
+ }
151
+ return constructor;
339
152
  }
340
153
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
341
154
  })(NativeCollections || (NativeCollections = {}));
342
155
  /* @internal */
343
- ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
344
- /* @internal */
345
- ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
156
+ ts.Map = NativeCollections.tryGetNativeMap();
346
157
  /* @internal */
347
- function getCollectionImplementation(name, nativeFactory, shimFactory) {
348
- var _a;
349
- // NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it.
350
- var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator);
351
- if (constructor)
352
- return constructor;
353
- throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");
354
- }
158
+ ts.Set = NativeCollections.tryGetNativeSet();
355
159
  })(ts || (ts = {}));
356
160
  /* @internal */
357
161
  var ts;
@@ -1067,15 +871,18 @@ var ts;
1067
871
  function insertSorted(array, insert, compare, allowDuplicates) {
1068
872
  if (array.length === 0) {
1069
873
  array.push(insert);
1070
- return;
874
+ return true;
1071
875
  }
1072
876
  var insertIndex = binarySearch(array, insert, identity, compare);
1073
877
  if (insertIndex < 0) {
1074
878
  array.splice(~insertIndex, 0, insert);
879
+ return true;
1075
880
  }
1076
- else if (allowDuplicates) {
881
+ if (allowDuplicates) {
1077
882
  array.splice(insertIndex, 0, insert);
883
+ return true;
1078
884
  }
885
+ return false;
1079
886
  }
1080
887
  ts.insertSorted = insertSorted;
1081
888
  function sortAndDeduplicate(array, comparer, equalityComparer) {
@@ -8036,12 +7843,9 @@ var ts;
8036
7843
  * Normalize path separators, converting `\` into `/`.
8037
7844
  */
8038
7845
  function normalizeSlashes(path) {
8039
- var index = path.indexOf("\\");
8040
- if (index === -1) {
8041
- return path;
8042
- }
8043
- backslashRegExp.lastIndex = index; // prime regex with known position
8044
- return path.replace(backslashRegExp, ts.directorySeparator);
7846
+ return path.indexOf("\\") !== -1
7847
+ ? path.replace(backslashRegExp, ts.directorySeparator)
7848
+ : path;
8045
7849
  }
8046
7850
  ts.normalizeSlashes = normalizeSlashes;
8047
7851
  /**
@@ -9742,6 +9546,7 @@ var ts;
9742
9546
  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."),
9743
9547
  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"),
9744
9548
  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"),
9549
+ 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}'"),
9745
9550
  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}'"),
9746
9551
  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."),
9747
9552
  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."),
@@ -19585,21 +19390,17 @@ var ts;
19585
19390
  return getStringFromExpandedCharCodes(expandedCharCodes);
19586
19391
  }
19587
19392
  ts.base64decode = base64decode;
19393
+ function readJsonOrUndefined(path, hostOrText) {
19394
+ var jsonText = ts.isString(hostOrText) ? hostOrText : hostOrText.readFile(path);
19395
+ if (!jsonText)
19396
+ return undefined;
19397
+ // gracefully handle if readFile fails or returns not JSON
19398
+ var result = ts.parseConfigFileTextToJson(path, jsonText);
19399
+ return !result.error ? result.config : undefined;
19400
+ }
19401
+ ts.readJsonOrUndefined = readJsonOrUndefined;
19588
19402
  function readJson(path, host) {
19589
- try {
19590
- var jsonText = host.readFile(path);
19591
- if (!jsonText)
19592
- return {};
19593
- var result = ts.parseConfigFileTextToJson(path, jsonText);
19594
- if (result.error) {
19595
- return {};
19596
- }
19597
- return result.config;
19598
- }
19599
- catch (e) {
19600
- // gracefully handle if readFile fails or returns not JSON
19601
- return {};
19602
- }
19403
+ return readJsonOrUndefined(path, host) || {};
19603
19404
  }
19604
19405
  ts.readJson = readJson;
19605
19406
  function directoryProbablyExists(directoryName, host) {
@@ -27950,9 +27751,10 @@ var ts;
27950
27751
  };
27951
27752
  var buildInfo_1;
27952
27753
  var getAndCacheBuildInfo_1 = function (getText) {
27754
+ var _a;
27953
27755
  if (buildInfo_1 === undefined) {
27954
27756
  var result = getText();
27955
- buildInfo_1 = result !== undefined ? ts.getBuildInfo(result) : false;
27757
+ buildInfo_1 = result !== undefined ? (_a = ts.getBuildInfo(node.buildInfoPath, result)) !== null && _a !== void 0 ? _a : false : false;
27956
27758
  }
27957
27759
  return buildInfo_1 || undefined;
27958
27760
  };
@@ -46012,6 +45814,9 @@ var ts;
46012
45814
  case 203 /* BindingElement */:
46013
45815
  bindBindingElementFlow(node);
46014
45816
  break;
45817
+ case 164 /* Parameter */:
45818
+ bindParameterFlow(node);
45819
+ break;
46015
45820
  case 205 /* ObjectLiteralExpression */:
46016
45821
  case 204 /* ArrayLiteralExpression */:
46017
45822
  case 296 /* PropertyAssignment */:
@@ -46752,20 +46557,38 @@ var ts;
46752
46557
  }
46753
46558
  }
46754
46559
  function bindBindingElementFlow(node) {
46755
- if (ts.isBindingPattern(node.name)) {
46756
- // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46757
- // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46758
- // - `BindingElement: BindingPattern Initializer?`
46759
- // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46760
- // - `BindingElement: BindingPattern Initializer?`
46761
- bind(node.dotDotDotToken);
46762
- bind(node.propertyName);
46763
- bind(node.initializer);
46764
- bind(node.name);
46560
+ // When evaluating a binding pattern, the initializer is evaluated before the binding pattern, per:
46561
+ // - https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-iteratorbindinginitialization
46562
+ // - `BindingElement: BindingPattern Initializer?`
46563
+ // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization
46564
+ // - `BindingElement: BindingPattern Initializer?`
46565
+ bind(node.dotDotDotToken);
46566
+ bind(node.propertyName);
46567
+ bindInitializer(node.initializer);
46568
+ bind(node.name);
46569
+ }
46570
+ function bindParameterFlow(node) {
46571
+ bindEach(node.modifiers);
46572
+ bind(node.dotDotDotToken);
46573
+ bind(node.questionToken);
46574
+ bind(node.type);
46575
+ bindInitializer(node.initializer);
46576
+ bind(node.name);
46577
+ }
46578
+ // a BindingElement/Parameter does not have side effects if initializers are not evaluated and used. (see GH#49759)
46579
+ function bindInitializer(node) {
46580
+ if (!node) {
46581
+ return;
46765
46582
  }
46766
- else {
46767
- bindEachChild(node);
46583
+ var entryFlow = currentFlow;
46584
+ bind(node);
46585
+ if (entryFlow === unreachableFlow || entryFlow === currentFlow) {
46586
+ return;
46768
46587
  }
46588
+ var exitFlow = createBranchLabel();
46589
+ addAntecedent(exitFlow, entryFlow);
46590
+ addAntecedent(exitFlow, currentFlow);
46591
+ currentFlow = finishFlowLabel(exitFlow);
46769
46592
  }
46770
46593
  function bindJSDocTypeAlias(node) {
46771
46594
  bind(node.tagName);
@@ -49936,7 +49759,7 @@ var ts;
49936
49759
  if (unidirectional === void 0) { unidirectional = false; }
49937
49760
  source.forEach(function (sourceSymbol, id) {
49938
49761
  var targetSymbol = target.get(id);
49939
- target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
49762
+ target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : getMergedSymbol(sourceSymbol));
49940
49763
  });
49941
49764
  }
49942
49765
  function mergeModuleAugmentation(moduleName) {
@@ -56727,11 +56550,9 @@ var ts;
56727
56550
  return getReturnTypeOfSignature(getterSignature);
56728
56551
  }
56729
56552
  }
56730
- if (ts.isInJSFile(declaration)) {
56731
- var type_1 = getParameterTypeOfTypeTag(func, declaration);
56732
- if (type_1)
56733
- return type_1;
56734
- }
56553
+ var parameterTypeOfTypeTag = getParameterTypeOfTypeTag(func, declaration);
56554
+ if (parameterTypeOfTypeTag)
56555
+ return parameterTypeOfTypeTag;
56735
56556
  // Use contextual parameter type if one is available
56736
56557
  var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
56737
56558
  if (type) {
@@ -57307,9 +57128,9 @@ var ts;
57307
57128
  if (typeNode === undefined) {
57308
57129
  return useUnknownInCatchVariables ? unknownType : anyType;
57309
57130
  }
57310
- var type_2 = getTypeOfNode(typeNode);
57131
+ var type_1 = getTypeOfNode(typeNode);
57311
57132
  // an errorType will make `checkTryStatement` issue an error
57312
- return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
57133
+ return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
57313
57134
  }
57314
57135
  // Handle export default expressions
57315
57136
  if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
@@ -57519,11 +57340,11 @@ var ts;
57519
57340
  return errorType;
57520
57341
  }
57521
57342
  var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */));
57522
- var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57343
+ var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
57523
57344
  if (!popTypeResolution()) {
57524
57345
  return reportCircularityError(symbol);
57525
57346
  }
57526
- return type_3;
57347
+ return type_2;
57527
57348
  }
57528
57349
  }
57529
57350
  var type = createObjectType(16 /* Anonymous */, symbol);
@@ -59746,10 +59567,10 @@ var ts;
59746
59567
  var baseTypes = [];
59747
59568
  var different = false;
59748
59569
  for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
59749
- var type_4 = types_7[_i];
59750
- var baseType = getBaseConstraint(type_4);
59570
+ var type_3 = types_7[_i];
59571
+ var baseType = getBaseConstraint(type_3);
59751
59572
  if (baseType) {
59752
- if (baseType !== type_4) {
59573
+ if (baseType !== type_3) {
59753
59574
  different = true;
59754
59575
  }
59755
59576
  baseTypes.push(baseType);
@@ -60540,7 +60361,12 @@ var ts;
60540
60361
  continue;
60541
60362
  }
60542
60363
  }
60543
- result.push(getSignatureFromDeclaration(decl));
60364
+ // If this is a function or method declaration, get the signature from the @type tag for the sake of optional parameters.
60365
+ // 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.
60366
+ result.push((!ts.isFunctionExpressionOrArrowFunction(decl) &&
60367
+ !ts.isObjectLiteralMethod(decl) &&
60368
+ getSignatureOfTypeTag(decl)) ||
60369
+ getSignatureFromDeclaration(decl));
60544
60370
  }
60545
60371
  return result;
60546
60372
  }
@@ -60571,7 +60397,7 @@ var ts;
60571
60397
  else {
60572
60398
  var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
60573
60399
  var jsdocPredicate = void 0;
60574
- if (!type && ts.isInJSFile(signature.declaration)) {
60400
+ if (!type) {
60575
60401
  var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
60576
60402
  if (jsdocSignature && signature !== jsdocSignature) {
60577
60403
  jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
@@ -64597,15 +64423,14 @@ var ts;
64597
64423
  return false;
64598
64424
  }
64599
64425
  function isContextSensitiveFunctionLikeDeclaration(node) {
64600
- return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
64601
- (ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
64426
+ return ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node);
64602
64427
  }
64603
64428
  function hasContextSensitiveReturnExpression(node) {
64604
64429
  // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value.
64605
64430
  return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body);
64606
64431
  }
64607
64432
  function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
64608
- return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64433
+ return (ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
64609
64434
  isContextSensitiveFunctionLikeDeclaration(func);
64610
64435
  }
64611
64436
  function getTypeWithoutSignatures(type) {
@@ -73663,9 +73488,11 @@ var ts;
73663
73488
  case 1 /* ExportsProperty */:
73664
73489
  case 6 /* Prototype */:
73665
73490
  case 3 /* PrototypeProperty */:
73666
- var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
73667
- // falls through
73668
73491
  case 2 /* ModuleExports */:
73492
+ var valueDeclaration = void 0;
73493
+ if (kind !== 2 /* ModuleExports */) {
73494
+ valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
73495
+ }
73669
73496
  valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration);
73670
73497
  var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration);
73671
73498
  return annotated ? getTypeFromTypeNode(annotated) : undefined;
@@ -74143,9 +73970,18 @@ var ts;
74143
73970
  if (!isErrorType(intrinsicClassAttribs)) {
74144
73971
  var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
74145
73972
  var hostClassType = getReturnTypeOfSignature(sig);
74146
- apparentAttributesType = intersectTypes(typeParams
74147
- ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
74148
- : intrinsicClassAttribs, apparentAttributesType);
73973
+ var libraryManagedAttributeType = void 0;
73974
+ if (typeParams && typeParams.length === 1) {
73975
+ var inferredArgs = fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context));
73976
+ libraryManagedAttributeType = instantiateType(intrinsicClassAttribs, createTypeMapper(typeParams, inferredArgs));
73977
+ }
73978
+ else if (typeParams)
73979
+ libraryManagedAttributeType = undefined;
73980
+ else
73981
+ libraryManagedAttributeType = intrinsicClassAttribs;
73982
+ if (libraryManagedAttributeType) {
73983
+ apparentAttributesType = intersectTypes(libraryManagedAttributeType, apparentAttributesType);
73984
+ }
74149
73985
  }
74150
73986
  var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
74151
73987
  if (!isErrorType(intrinsicAttribs)) {
@@ -74650,16 +74486,30 @@ var ts;
74650
74486
  // If object literal is contextually typed by the implied type of a binding pattern, augment the result
74651
74487
  // type with those properties for which the binding pattern specifies a default value.
74652
74488
  // If the object literal is spread into another object literal, skip this step and let the top-level object
74653
- // literal handle it instead.
74654
- if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) {
74655
- for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74656
- var prop = _e[_d];
74657
- if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74658
- if (!(prop.flags & 16777216 /* Optional */)) {
74659
- error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74489
+ // literal handle it instead. Note that this might require full traversal to the root pattern's parent
74490
+ // as it's the guaranteed to be the common ancestor of the pattern node and the current object node.
74491
+ // It's not possible to check if the immediate parent node is a spread assignment
74492
+ // since the type flows in non-obvious ways through conditional expressions, IIFEs and more.
74493
+ if (contextualTypeHasPattern) {
74494
+ var rootPatternParent_1 = ts.findAncestor(contextualType.pattern.parent, function (n) {
74495
+ return n.kind === 254 /* VariableDeclaration */ ||
74496
+ n.kind === 221 /* BinaryExpression */ ||
74497
+ n.kind === 164 /* Parameter */;
74498
+ });
74499
+ var spreadOrOutsideRootObject = ts.findAncestor(node, function (n) {
74500
+ return n === rootPatternParent_1 ||
74501
+ n.kind === 298 /* SpreadAssignment */;
74502
+ });
74503
+ if (spreadOrOutsideRootObject.kind !== 298 /* SpreadAssignment */) {
74504
+ for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
74505
+ var prop = _e[_d];
74506
+ if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
74507
+ if (!(prop.flags & 16777216 /* Optional */)) {
74508
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
74509
+ }
74510
+ propertiesTable.set(prop.escapedName, prop);
74511
+ propertiesArray.push(prop);
74660
74512
  }
74661
- propertiesTable.set(prop.escapedName, prop);
74662
- propertiesArray.push(prop);
74663
74513
  }
74664
74514
  }
74665
74515
  }
@@ -77958,12 +77808,15 @@ var ts;
77958
77808
  return false;
77959
77809
  }
77960
77810
  var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
77961
- ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
77811
+ (ts.isVariableDeclaration(node) || ts.isPropertyAssignment(node)) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
77962
77812
  undefined;
77963
77813
  if (func) {
77964
- // If the node has a @class tag, treat it like a constructor.
77814
+ // If the node has a @class or @constructor tag, treat it like a constructor.
77965
77815
  if (ts.getJSDocClassTag(node))
77966
77816
  return true;
77817
+ // If the node is a property of an object literal.
77818
+ if (ts.isPropertyAssignment(ts.walkUpParenthesizedExpressions(func.parent)))
77819
+ return false;
77967
77820
  // If the symbol of the node has members, treat it like a constructor.
77968
77821
  var symbol = getSymbolOfNode(func);
77969
77822
  return !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.members) === null || _a === void 0 ? void 0 : _a.size);
@@ -78211,8 +78064,8 @@ var ts;
78211
78064
  if (hasDefaultOnly && type && !isErrorType(type)) {
78212
78065
  var synthType = type;
78213
78066
  if (!synthType.defaultOnlyType) {
78214
- var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78215
- synthType.defaultOnlyType = type_5;
78067
+ var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
78068
+ synthType.defaultOnlyType = type_4;
78216
78069
  }
78217
78070
  return synthType.defaultOnlyType;
78218
78071
  }
@@ -87549,6 +87402,12 @@ var ts;
87549
87402
  return resolveJSDocMemberName(name, /*ignoreErrors*/ false, getSymbolOfNode(container));
87550
87403
  }
87551
87404
  }
87405
+ if (result && isJSDoc_1) {
87406
+ var container = ts.getJSDocHost(name);
87407
+ if (container && ts.isEnumMember(container) && container === result.valueDeclaration) {
87408
+ return resolveEntityName(name, meaning, /*ignoreErrors*/ true, /* dontResolveAlias */ true, ts.getSourceFileOfNode(container)) || result;
87409
+ }
87410
+ }
87552
87411
  return result;
87553
87412
  }
87554
87413
  else if (ts.isPrivateIdentifier(name)) {
@@ -107710,6 +107569,13 @@ var ts;
107710
107569
  ts.Debug.assert(importVariableName !== undefined);
107711
107570
  // save import into the local
107712
107571
  statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
107572
+ if (ts.hasSyntacticModifier(entry, 1 /* Export */)) {
107573
+ statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction,
107574
+ /*typeArguments*/ undefined, [
107575
+ factory.createStringLiteral(ts.idText(importVariableName)),
107576
+ parameterName,
107577
+ ])));
107578
+ }
107713
107579
  break;
107714
107580
  case 272 /* ExportDeclaration */:
107715
107581
  ts.Debug.assert(importVariableName !== undefined);
@@ -110552,8 +110418,12 @@ var ts;
110552
110418
  }
110553
110419
  var previousNeedsDeclare = needsDeclare;
110554
110420
  switch (input.kind) {
110555
- case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all
110556
- return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110421
+ case 259 /* TypeAliasDeclaration */: {
110422
+ needsDeclare = false;
110423
+ var clean = cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
110424
+ needsDeclare = previousNeedsDeclare;
110425
+ return clean;
110426
+ }
110557
110427
  case 258 /* InterfaceDeclaration */: {
110558
110428
  return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
110559
110429
  }
@@ -112057,8 +111927,8 @@ var ts;
112057
111927
  }
112058
111928
  ts.getBuildInfoText = getBuildInfoText;
112059
111929
  /*@internal*/
112060
- function getBuildInfo(buildInfoText) {
112061
- return JSON.parse(buildInfoText);
111930
+ function getBuildInfo(buildInfoFile, buildInfoText) {
111931
+ return ts.readJsonOrUndefined(buildInfoFile, buildInfoText);
112062
111932
  }
112063
111933
  ts.getBuildInfo = getBuildInfo;
112064
111934
  /*@internal*/
@@ -112136,17 +112006,16 @@ var ts;
112136
112006
  var buildInfo;
112137
112007
  if (host.getBuildInfo) {
112138
112008
  // If host directly provides buildinfo we can get it directly. This allows host to cache the buildinfo
112139
- var hostBuildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
112140
- if (!hostBuildInfo)
112141
- return buildInfoPath;
112142
- buildInfo = hostBuildInfo;
112009
+ buildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
112143
112010
  }
112144
112011
  else {
112145
112012
  var buildInfoText = host.readFile(buildInfoPath);
112146
112013
  if (!buildInfoText)
112147
112014
  return buildInfoPath;
112148
- buildInfo = getBuildInfo(buildInfoText);
112015
+ buildInfo = getBuildInfo(buildInfoPath, buildInfoText);
112149
112016
  }
112017
+ if (!buildInfo)
112018
+ return buildInfoPath;
112150
112019
  if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationFilePath && !buildInfo.bundle.dts))
112151
112020
  return buildInfoPath;
112152
112021
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
@@ -116804,7 +116673,16 @@ var ts;
116804
116673
  return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
116805
116674
  }
116806
116675
  function getCachedFileSystemEntriesForBaseDir(path) {
116807
- return getCachedFileSystemEntries(ts.getDirectoryPath(path));
116676
+ var entries = getCachedFileSystemEntries(ts.getDirectoryPath(path));
116677
+ if (!entries) {
116678
+ return entries;
116679
+ }
116680
+ // If we're looking for the base directory, we're definitely going to search the entries
116681
+ if (!entries.sortedAndCanonicalizedFiles) {
116682
+ entries.sortedAndCanonicalizedFiles = entries.files.map(getCanonicalFileName).sort();
116683
+ entries.sortedAndCanonicalizedDirectories = entries.directories.map(getCanonicalFileName).sort();
116684
+ }
116685
+ return entries;
116808
116686
  }
116809
116687
  function getBaseNameOfFileName(fileName) {
116810
116688
  return ts.getBaseFileName(ts.normalizePath(fileName));
@@ -116847,21 +116725,10 @@ var ts;
116847
116725
  return undefined;
116848
116726
  }
116849
116727
  }
116850
- function fileNameEqual(name1, name2) {
116851
- return getCanonicalFileName(name1) === getCanonicalFileName(name2);
116852
- }
116853
116728
  function hasEntry(entries, name) {
116854
- return ts.some(entries, function (file) { return fileNameEqual(file, name); });
116855
- }
116856
- function updateFileSystemEntry(entries, baseName, isValid) {
116857
- if (hasEntry(entries, baseName)) {
116858
- if (!isValid) {
116859
- return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
116860
- }
116861
- }
116862
- else if (isValid) {
116863
- return entries.push(baseName);
116864
- }
116729
+ // Case-sensitive comparison since already canonicalized
116730
+ var index = ts.binarySearch(entries, name, ts.identity, ts.compareStringsCaseSensitive);
116731
+ return index >= 0;
116865
116732
  }
116866
116733
  function writeFile(fileName, data, writeByteOrderMark) {
116867
116734
  var path = toPath(fileName);
@@ -116874,7 +116741,7 @@ var ts;
116874
116741
  function fileExists(fileName) {
116875
116742
  var path = toPath(fileName);
116876
116743
  var result = getCachedFileSystemEntriesForBaseDir(path);
116877
- return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
116744
+ return result && hasEntry(result.sortedAndCanonicalizedFiles, getCanonicalFileName(getBaseNameOfFileName(fileName))) ||
116878
116745
  host.fileExists(fileName);
116879
116746
  }
116880
116747
  function directoryExists(dirPath) {
@@ -116884,9 +116751,14 @@ var ts;
116884
116751
  function createDirectory(dirPath) {
116885
116752
  var path = toPath(dirPath);
116886
116753
  var result = getCachedFileSystemEntriesForBaseDir(path);
116887
- var baseFileName = getBaseNameOfFileName(dirPath);
116888
116754
  if (result) {
116889
- updateFileSystemEntry(result.directories, baseFileName, /*isValid*/ true);
116755
+ var baseName = getBaseNameOfFileName(dirPath);
116756
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
116757
+ var canonicalizedDirectories = result.sortedAndCanonicalizedDirectories;
116758
+ // Case-sensitive comparison since already canonicalized
116759
+ if (ts.insertSorted(canonicalizedDirectories, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
116760
+ result.directories.push(baseName);
116761
+ }
116890
116762
  }
116891
116763
  host.createDirectory(dirPath);
116892
116764
  }
@@ -116955,7 +116827,7 @@ var ts;
116955
116827
  fileExists: host.fileExists(fileOrDirectoryPath),
116956
116828
  directoryExists: host.directoryExists(fileOrDirectoryPath)
116957
116829
  };
116958
- if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
116830
+ if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
116959
116831
  // Folder added or removed, clear the cache instead of updating the folder and its structure
116960
116832
  clearCache();
116961
116833
  }
@@ -116975,7 +116847,23 @@ var ts;
116975
116847
  }
116976
116848
  }
116977
116849
  function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
116978
- updateFileSystemEntry(parentResult.files, baseName, fileExists);
116850
+ var canonicalizedFiles = parentResult.sortedAndCanonicalizedFiles;
116851
+ var canonicalizedBaseName = getCanonicalFileName(baseName);
116852
+ if (fileExists) {
116853
+ // Case-sensitive comparison since already canonicalized
116854
+ if (ts.insertSorted(canonicalizedFiles, canonicalizedBaseName, ts.compareStringsCaseSensitive)) {
116855
+ parentResult.files.push(baseName);
116856
+ }
116857
+ }
116858
+ else {
116859
+ // Case-sensitive comparison since already canonicalized
116860
+ var sortedIndex = ts.binarySearch(canonicalizedFiles, canonicalizedBaseName, ts.identity, ts.compareStringsCaseSensitive);
116861
+ if (sortedIndex >= 0) {
116862
+ canonicalizedFiles.splice(sortedIndex, 1);
116863
+ var unsortedIndex = parentResult.files.findIndex(function (entry) { return getCanonicalFileName(entry) === canonicalizedBaseName; });
116864
+ parentResult.files.splice(unsortedIndex, 1);
116865
+ }
116866
+ }
116979
116867
  }
116980
116868
  function clearCache() {
116981
116869
  cachedReadDirectoryResult.clear();
@@ -125213,18 +125101,14 @@ var ts;
125213
125101
  if (host.getBuildInfo) {
125214
125102
  // host provides buildinfo, get it from there. This allows host to cache it
125215
125103
  buildInfo = host.getBuildInfo(buildInfoPath, compilerOptions.configFilePath);
125216
- if (!buildInfo)
125217
- return undefined;
125218
125104
  }
125219
125105
  else {
125220
125106
  var content = host.readFile(buildInfoPath);
125221
125107
  if (!content)
125222
125108
  return undefined;
125223
- buildInfo = ts.getBuildInfo(content);
125109
+ buildInfo = ts.getBuildInfo(buildInfoPath, content);
125224
125110
  }
125225
- if (buildInfo.version !== ts.version)
125226
- return undefined;
125227
- if (!buildInfo.program)
125111
+ if (!buildInfo || buildInfo.version !== ts.version || !buildInfo.program)
125228
125112
  return undefined;
125229
125113
  return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
125230
125114
  }
@@ -125446,7 +125330,8 @@ var ts;
125446
125330
  }
125447
125331
  // All resolutions are invalid if user provided resolutions
125448
125332
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
125449
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
125333
+ var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
125334
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
125450
125335
  if (hasChangedConfigFileParsingErrors) {
125451
125336
  if (reportFileChangeDetectedOnCreateProgram) {
125452
125337
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -125465,6 +125350,11 @@ var ts;
125465
125350
  if (host.afterProgramCreate && program !== builderProgram) {
125466
125351
  host.afterProgramCreate(builderProgram);
125467
125352
  }
125353
+ compilerHost.readFile = originalReadFile;
125354
+ compilerHost.fileExists = originalFileExists;
125355
+ compilerHost.directoryExists = originalDirectoryExists;
125356
+ compilerHost.createDirectory = originalCreateDirectory;
125357
+ compilerHost.writeFile = originalWriteFile;
125468
125358
  return builderProgram;
125469
125359
  }
125470
125360
  function createNewProgram(hasInvalidatedResolution) {
@@ -125942,19 +125832,20 @@ var ts;
125942
125832
  */
125943
125833
  UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
125944
125834
  UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
125945
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
125946
- UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
125947
- UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 7] = "OutOfDateBuildInfo";
125948
- UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 8] = "UpstreamOutOfDate";
125949
- UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 9] = "UpstreamBlocked";
125950
- UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 10] = "ComputingUpstream";
125951
- UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 11] = "TsVersionOutputOfDate";
125952
- UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 12] = "UpToDateWithInputFileText";
125835
+ UpToDateStatusType[UpToDateStatusType["ErrorReadingFile"] = 5] = "ErrorReadingFile";
125836
+ UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 6] = "OutOfDateWithSelf";
125837
+ UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 7] = "OutOfDateWithUpstream";
125838
+ UpToDateStatusType[UpToDateStatusType["OutOfDateBuildInfo"] = 8] = "OutOfDateBuildInfo";
125839
+ UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 9] = "UpstreamOutOfDate";
125840
+ UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 10] = "UpstreamBlocked";
125841
+ UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 11] = "ComputingUpstream";
125842
+ UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 12] = "TsVersionOutputOfDate";
125843
+ UpToDateStatusType[UpToDateStatusType["UpToDateWithInputFileText"] = 13] = "UpToDateWithInputFileText";
125953
125844
  /**
125954
125845
  * Projects with no outputs (i.e. "solution" files)
125955
125846
  */
125956
- UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 13] = "ContainerOnly";
125957
- UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild";
125847
+ UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 14] = "ContainerOnly";
125848
+ UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 15] = "ForceBuild";
125958
125849
  })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
125959
125850
  function resolveConfigFileProjectName(project) {
125960
125851
  if (ts.fileExtensionIs(project, ".json" /* Json */)) {
@@ -126656,13 +126547,13 @@ var ts;
126656
126547
  var emitterDiagnostics = ts.createDiagnosticCollection();
126657
126548
  var emittedOutputs = new ts.Map();
126658
126549
  var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
126659
- var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo;
126550
+ var existingBuildInfo = state.buildInfoCache.get(projectPath).buildInfo || undefined;
126660
126551
  outputFiles.forEach(function (_a) {
126661
126552
  var _b, _c;
126662
126553
  var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo;
126663
126554
  emittedOutputs.set(toPath(state, name), name);
126664
126555
  if (buildInfo) {
126665
- if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) {
126556
+ 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)) {
126666
126557
  resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
126667
126558
  }
126668
126559
  setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags);
@@ -126955,8 +126846,7 @@ var ts;
126955
126846
  return existing.buildInfo || undefined;
126956
126847
  }
126957
126848
  var value = state.readFileWithCache(buildInfoPath);
126958
- var buildInfo = value ? ts.getBuildInfo(value) : undefined;
126959
- ts.Debug.assert(modifiedTime || !buildInfo);
126849
+ var buildInfo = value ? ts.getBuildInfo(buildInfoPath, value) : undefined;
126960
126850
  state.buildInfoCache.set(resolvedConfigPath, { path: path, buildInfo: buildInfo || false, modifiedTime: modifiedTime || ts.missingFileModifiedTime });
126961
126851
  return buildInfo;
126962
126852
  }
@@ -127041,7 +126931,14 @@ var ts;
127041
126931
  missingOutputFileName: buildInfoPath
127042
126932
  };
127043
126933
  }
127044
- var buildInfo = ts.Debug.checkDefined(getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime));
126934
+ var buildInfo = getBuildInfo(state, buildInfoPath, resolvedPath, buildInfoTime);
126935
+ if (!buildInfo) {
126936
+ // Error reading buildInfo
126937
+ return {
126938
+ type: ts.UpToDateStatusType.ErrorReadingFile,
126939
+ fileName: buildInfoPath
126940
+ };
126941
+ }
127045
126942
  if ((buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
127046
126943
  return {
127047
126944
  type: ts.UpToDateStatusType.TsVersionOutputOfDate,
@@ -127699,6 +127596,8 @@ var ts;
127699
127596
  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));
127700
127597
  case ts.UpToDateStatusType.OutputMissing:
127701
127598
  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));
127599
+ case ts.UpToDateStatusType.ErrorReadingFile:
127600
+ 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));
127702
127601
  case ts.UpToDateStatusType.OutOfDateBuildInfo:
127703
127602
  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));
127704
127603
  case ts.UpToDateStatusType.UpToDate:
@@ -157152,6 +157051,15 @@ var ts;
157152
157051
  ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code,
157153
157052
  ts.Diagnostics.Cannot_find_name_0.code
157154
157053
  ];
157054
+ var InfoKind;
157055
+ (function (InfoKind) {
157056
+ InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
157057
+ InfoKind[InfoKind["Enum"] = 1] = "Enum";
157058
+ InfoKind[InfoKind["Function"] = 2] = "Function";
157059
+ InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
157060
+ InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
157061
+ InfoKind[InfoKind["Signature"] = 5] = "Signature";
157062
+ })(InfoKind || (InfoKind = {}));
157155
157063
  codefix.registerCodeFix({
157156
157064
  errorCodes: errorCodes,
157157
157065
  getCodeActions: function (context) {
@@ -157160,19 +157068,19 @@ var ts;
157160
157068
  if (!info) {
157161
157069
  return undefined;
157162
157070
  }
157163
- if (info.kind === 3 /* ObjectLiteral */) {
157071
+ if (info.kind === InfoKind.ObjectLiteral) {
157164
157072
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); });
157165
157073
  return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)];
157166
157074
  }
157167
- if (info.kind === 4 /* JsxAttributes */) {
157075
+ if (info.kind === InfoKind.JsxAttributes) {
157168
157076
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); });
157169
157077
  return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)];
157170
157078
  }
157171
- if (info.kind === 2 /* Function */) {
157079
+ if (info.kind === InfoKind.Function || info.kind === InfoKind.Signature) {
157172
157080
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); });
157173
157081
  return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)];
157174
157082
  }
157175
- if (info.kind === 1 /* Enum */) {
157083
+ if (info.kind === InfoKind.Enum) {
157176
157084
  var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); });
157177
157085
  return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
157178
157086
  }
@@ -157190,20 +157098,20 @@ var ts;
157190
157098
  if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) {
157191
157099
  return;
157192
157100
  }
157193
- if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) {
157101
+ if (fixId === fixMissingFunctionDeclaration && (info.kind === InfoKind.Function || info.kind === InfoKind.Signature)) {
157194
157102
  addFunctionDeclaration(changes, context, info);
157195
157103
  }
157196
- else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
157104
+ else if (fixId === fixMissingProperties && info.kind === InfoKind.ObjectLiteral) {
157197
157105
  addObjectLiteralProperties(changes, context, info);
157198
157106
  }
157199
- else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
157107
+ else if (fixId === fixMissingAttributes && info.kind === InfoKind.JsxAttributes) {
157200
157108
  addJsxAttributes(changes, context, info);
157201
157109
  }
157202
157110
  else {
157203
- if (info.kind === 1 /* Enum */) {
157111
+ if (info.kind === InfoKind.Enum) {
157204
157112
  addEnumMemberDeclaration(changes, checker, info);
157205
157113
  }
157206
- if (info.kind === 0 /* TypeLikeDeclaration */) {
157114
+ if (info.kind === InfoKind.TypeLikeDeclaration) {
157207
157115
  var parentDeclaration = info.parentDeclaration, token_1 = info.token;
157208
157116
  var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; });
157209
157117
  if (!infos.some(function (i) { return i.token.text === token_1.text; })) {
@@ -157247,14 +157155,6 @@ var ts;
157247
157155
  }));
157248
157156
  },
157249
157157
  });
157250
- var InfoKind;
157251
- (function (InfoKind) {
157252
- InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
157253
- InfoKind[InfoKind["Enum"] = 1] = "Enum";
157254
- InfoKind[InfoKind["Function"] = 2] = "Function";
157255
- InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
157256
- InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
157257
- })(InfoKind || (InfoKind = {}));
157258
157158
  function getInfo(sourceFile, tokenPos, errorCode, checker, program) {
157259
157159
  // The identifier of the missing property. eg:
157260
157160
  // this.missing = 1;
@@ -157276,7 +157176,7 @@ var ts;
157276
157176
  var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
157277
157177
  if (!ts.length(properties))
157278
157178
  return undefined;
157279
- return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent };
157179
+ return { kind: InfoKind.ObjectLiteral, token: param.name, properties: properties, parentDeclaration: parent };
157280
157180
  }
157281
157181
  if (!ts.isMemberName(token))
157282
157182
  return undefined;
@@ -157284,17 +157184,26 @@ var ts;
157284
157184
  var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false));
157285
157185
  if (!ts.length(properties))
157286
157186
  return undefined;
157287
- return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer };
157187
+ return { kind: InfoKind.ObjectLiteral, token: token, properties: properties, parentDeclaration: parent.initializer };
157288
157188
  }
157289
157189
  if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) {
157290
157190
  var target = ts.getEmitScriptTarget(program.getCompilerOptions());
157291
157191
  var attributes = getUnmatchedAttributes(checker, target, token.parent);
157292
157192
  if (!ts.length(attributes))
157293
157193
  return undefined;
157294
- return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
157194
+ return { kind: InfoKind.JsxAttributes, token: token, attributes: attributes, parentDeclaration: token.parent };
157295
157195
  }
157296
- if (ts.isIdentifier(token) && ts.isCallExpression(parent) && parent.expression === token) {
157297
- return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile };
157196
+ if (ts.isIdentifier(token)) {
157197
+ var type = checker.getContextualType(token);
157198
+ if (type && ts.getObjectFlags(type) & 16 /* Anonymous */) {
157199
+ var signature = ts.firstOrUndefined(checker.getSignaturesOfType(type, 0 /* Call */));
157200
+ if (signature === undefined)
157201
+ return undefined;
157202
+ return { kind: InfoKind.Signature, token: token, signature: signature, sourceFile: sourceFile, parentDeclaration: findScope(token) };
157203
+ }
157204
+ if (ts.isCallExpression(parent) && parent.expression === token) {
157205
+ return { kind: InfoKind.Function, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: findScope(token) };
157206
+ }
157298
157207
  }
157299
157208
  if (!ts.isPropertyAccessExpression(parent))
157300
157209
  return undefined;
@@ -157306,13 +157215,13 @@ var ts;
157306
157215
  var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
157307
157216
  var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
157308
157217
  if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
157309
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration };
157218
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration };
157310
157219
  }
157311
157220
  var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
157312
157221
  if (sourceFile.commonJsModuleIndicator)
157313
157222
  return undefined;
157314
157223
  if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
157315
- return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile };
157224
+ return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile };
157316
157225
  }
157317
157226
  }
157318
157227
  var classDeclaration = ts.find(symbol.declarations, ts.isClassLike);
@@ -157330,11 +157239,11 @@ var ts;
157330
157239
  (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */);
157331
157240
  var isJSFile = ts.isSourceFileJS(declSourceFile);
157332
157241
  var call = ts.tryCast(parent.parent, ts.isCallExpression);
157333
- return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
157242
+ return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
157334
157243
  }
157335
157244
  var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
157336
157245
  if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
157337
- return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration };
157246
+ return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
157338
157247
  }
157339
157248
  return undefined;
157340
157249
  }
@@ -157510,9 +157419,17 @@ var ts;
157510
157419
  });
157511
157420
  }
157512
157421
  function addFunctionDeclaration(changes, context, info) {
157422
+ var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
157513
157423
  var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
157514
- var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration);
157515
- changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
157424
+ var functionDeclaration = info.kind === InfoKind.Function
157425
+ ? codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration)
157426
+ : 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);
157427
+ if (functionDeclaration === undefined) {
157428
+ ts.Debug.fail("fixMissingFunctionDeclaration codefix got unexpected error.");
157429
+ }
157430
+ ts.isReturnStatement(info.parentDeclaration)
157431
+ ? changes.insertNodeBefore(info.sourceFile, info.parentDeclaration, functionDeclaration, /*blankLineBetween*/ true)
157432
+ : changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
157516
157433
  importAdder.writeFixes(changes);
157517
157434
  }
157518
157435
  function addJsxAttributes(changes, context, info) {
@@ -157670,6 +157587,14 @@ var ts;
157670
157587
  }
157671
157588
  return ts.createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === 0 /* Single */);
157672
157589
  }
157590
+ function findScope(node) {
157591
+ if (ts.findAncestor(node, ts.isJsxExpression)) {
157592
+ var returnStatement = ts.findAncestor(node.parent, ts.isReturnStatement);
157593
+ if (returnStatement)
157594
+ return returnStatement;
157595
+ }
157596
+ return ts.getSourceFileOfNode(node);
157597
+ }
157673
157598
  })(codefix = ts.codefix || (ts.codefix = {}));
157674
157599
  })(ts || (ts = {}));
157675
157600
  /* @internal */
@@ -160359,6 +160284,9 @@ var ts;
160359
160284
  if (ts.isMethodDeclaration(signatureDeclaration)) {
160360
160285
  return ts.factory.updateMethodDeclaration(signatureDeclaration, modifiers, asteriskToken, name !== null && name !== void 0 ? name : ts.factory.createIdentifier(""), questionToken, typeParameters, parameters, type, body);
160361
160286
  }
160287
+ if (ts.isFunctionDeclaration(signatureDeclaration)) {
160288
+ return ts.factory.updateFunctionDeclaration(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body);
160289
+ }
160362
160290
  return undefined;
160363
160291
  }
160364
160292
  codefix.createSignatureDeclarationFromSignature = createSignatureDeclarationFromSignature;
@@ -167661,6 +167589,10 @@ var ts;
167661
167589
  getCurrentDirectory: compilerHost.getCurrentDirectory,
167662
167590
  onUnRecoverableConfigFileDiagnostic: ts.noop,
167663
167591
  };
167592
+ // The call to isProgramUptoDate below may refer back to documentRegistryBucketKey;
167593
+ // calculate this early so it's not undefined if downleveled to a var (or, if emitted
167594
+ // as a const variable without downleveling, doesn't crash).
167595
+ var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
167664
167596
  // If the program is already up-to-date, we can reuse it
167665
167597
  if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
167666
167598
  return;
@@ -167670,7 +167602,6 @@ var ts;
167670
167602
  // instance. If we cancel midway through, we may end up in an inconsistent state where
167671
167603
  // the program points to old source files that have been invalidated because of
167672
167604
  // incremental parsing.
167673
- var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
167674
167605
  var options = {
167675
167606
  rootNames: rootFileNames,
167676
167607
  options: newSettings,